WeKnora/cli/cmd/agent
VictorMaznyuk b94612a7ec
fix(agent): PUT no longer erases the avatar, and driver errors stay server-side (#3230)
* fix(agent): PUT no longer erases the avatar, and driver errors stay server-side

Two defects in the custom-agent API, both of which surface as a successful or
misleading response.

1. A config-only PUT wiped the avatar.

   UpdateAgentRequest.Avatar was a plain string, so "field omitted" and
   "explicit clear" were indistinguishable, and UpdateAgent assigned it
   unconditionally. Any caller that updated only the config — which is what
   an edit form or an SDK client does when it sends the config it changed —
   silently zeroed the avatar and still received 200.

   Avatar now travels as *string end to end: nil keeps the stored value, a
   pointer to "" is an explicit clear. The service takes it as a separate
   argument because *types.CustomAgent cannot express the difference.

2. Raw repository/driver errors reached the client.

   The fallback branches forwarded err.Error() verbatim, so a postgres
   message — for example "ERROR: value too long for type character
   varying(64) (SQLSTATE 22001)" — was returned in the API response. That
   leaks schema details and tells the caller nothing actionable. Each
   fallback now returns a fixed message naming the operation; the full error
   is still logged immediately above, so nothing is lost for diagnosis.

   The same oversized-avatar case is now rejected earlier, by ValidateAvatar,
   as a 400 that names the varchar(64) limit instead of a 500 produced by the
   database.

Typed sentinels and *errors.AppError keep their existing behaviour — only the
untyped fallbacks changed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(agent): complete avatar preservation and regression coverage

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-09-14 20:50:15 +08:00
..
agent.go feat(cli): agent-first WeKnora CLI 2026-07-06 22:53:01 +08:00
check.go refactor(cli): resource-command refactors — --kb resolver, MCP session_ask, session stop (BREAKING) 2026-06-08 20:18:43 +08:00
check_test.go feat(cli): --format json default + NDJSON event stream + context→profile cascade + help calibration + docs (BREAKING) 2026-05-27 10:56:34 +08:00
create.go feat(cli)!: v0.10 reliability, agent-UX, and command-surface hardening 2026-07-06 22:53:01 +08:00
create_test.go fix(agent): PUT no longer erases the avatar, and driver errors stay server-side (#3230) 2026-09-14 20:50:15 +08:00
delete.go feat(cli)!: v0.10 reliability, agent-UX, and command-surface hardening 2026-07-06 22:53:01 +08:00
delete_test.go feat(cli): --format json default + NDJSON event stream + context→profile cascade + help calibration + docs (BREAKING) 2026-05-27 10:56:34 +08:00
edit.go fix(cli): preserve agent update flags in retry_argv 2026-08-10 19:33:39 +08:00
edit_dry_run_test.go feat(cli): --dry-run + risk metadata + validation parity on 19 mutations 2026-05-28 19:29:50 +08:00
edit_test.go fix(agent): PUT no longer erases the avatar, and driver errors stay server-side (#3230) 2026-09-14 20:50:15 +08:00
list.go feat(cli): agent-first WeKnora CLI 2026-07-06 22:53:01 +08:00
list_test.go feat(cli): agent-first WeKnora CLI 2026-07-06 22:53:01 +08:00
status.go refactor(cli): resource-command refactors — --kb resolver, MCP session_ask, session stop (BREAKING) 2026-06-08 20:18:43 +08:00
status_test.go feat(cli): --format json default + NDJSON event stream + context→profile cascade + help calibration + docs (BREAKING) 2026-05-27 10:56:34 +08:00
view.go feat(agent): keep long sandbox turns from truncating, overflowing, or rewriting files 2026-09-02 22:09:09 +08:00
view_test.go feat(cli): --format json default + NDJSON event stream + context→profile cascade + help calibration + docs (BREAKING) 2026-05-27 10:56:34 +08:00