Repository navigation
fix(platform): name the refused field at the app doors and in forms - #3538
Merged
Merged
Conversation
About 190 app doors answered a body their schema refused with a bare
`{ error: 'invalid body' }`: the dialog could only say "invalid body",
and the error report carried the same opaque code, so nobody could tell
which field the form had let through.
Every door now answers through `backend/lib/invalid-body-response.ts`:
the same `invalid body` code, a `field: reason` message and the issues
under `data.issues`. `invalidBodyIssuesResponse` covers a refusal no
schema raised (a body that is not JSON, the automation save's missing
`document`). An email with neither body nor files is refused at
`content`. A guard test fails any bare literal left under `backend/`.
The caps a form has to mirror now live where the app can read them:
the contact caps beside the contact patterns in `lib/shared`, the
object-storage connection caps in its shared schema, and the Postgres
host rule and password cap in `@tale/shared/schemas/knowledge`.
The UI evaluations kept hitting `invalid body` on Products, Contacts and Data residency (TALE-84, TALE-162, TALE-103): each form let through a value the door refuses. - Contacts: the form trims and caps Name (300), Email (320, at most 64 characters before the `@`), Phone (50) and Locale (20) with the shared caps, and both dialogs put a refused body's reason on the toast. - Products: a pasted image address must be an absolute http(s) URL (or the app path an upload returned); the error sits under Image URL. - Data residency: Test connection checks the fields the way Save does and names what it would refuse instead of sending it; required fields are judged trimmed, as they are sent, and every field has the door's length cap. - The default mutation and action toasts (and the task toasts) show an `invalid body` refusal's field-naming sentence instead of "Try again". New `products.edit.validation.imageUrl` in en, de and fr; the product and self-hosted data-residency docs say what the forms check, in all three languages. Manual boxes KNOW-B13 and DATA-B8, with the owning specs in the automation register.
The workspace-tool bridge kept only the code of a domain refusal. An agent's task_create with a description over 20,000 code units or a label over 50 came back as "TASK_DESCRIPTION_INVALID: the domain refused these arguments.", so the model could not tell which limit it broke. The domain threw one "Invalid title" for an empty and an over-long title on the human create and edit paths, and the tasks app door dropped the domain's message altogether. - core/tasks/helpers.ts now holds the refusal sentences beside the limits. Each names the cap, the unit every cap is measured in (UTF-16 code units, where most emoji count as 2) and the length measured, never the value. validateTitle tells an empty title from an over-long one, and the description, label count, label name and comment caps are named. - toolResultFromError relays the domain's sentence beside the code, and nothing else from the refusal's payload. - The agent-comment writer moves into the coded write shim, so an over-long comment answers invalid_args instead of error. - workspace_status states every cap of task_create, task_comment and task_upsert_by_external_ref from the shared constants, in code units. - The tasks app door answers a domain refusal with its message, and an empty title on create reaches the domain instead of a bare invalid body. Closes #3155
asAppError translated every error carrying a string code and a numeric status, so a MentionDirectoryError (503) on an agent comment reached the model as invalid_args and was audited so. Only a 4xx refusal is translated now; a coded 5xx stays a plain error and answers `error`.
…ence A blank or whitespace-only title at the tool door still answered the generic 'needs a non-empty "title" string', naming neither the range nor its unit. It now answers taskTitleRefusal's empty sentence, the one the domain's validateTitle throws; a missing or non-string title keeps the generic text.
The tasks door's schema carried caps of its own above the domain's (a
title up to 500, a description up to 50,000, up to 100 labels, a comment
min(1)), and anything it refused answered a bare `invalid body` that
could not tell an empty title or comment from an over-long one. The
title, description, label count and comment body are now checked with
the domain's own refusal helpers and answer `{error: <code>, message}`,
before a rate-limit slot is spent.
A task refusal's sentence now reaches the app door and an agent's tool result, yet SETUP_FOLDER_MISSING echoed the setup folder name it was sent. The sentence names the rule instead, and a guard reads every TaskError, TaskReviewError and task-domain ProjectError message so a new interpolated value fails until it is made static or reviewed.
The REST reference and the house schema messages said "characters" for the task title, description, label, comment and translation caps, which count UTF-16 code units like the domain's refusals. The schema messages and the en/de/fr reference now name the unit.
The row for named task limits now covers the app door's schema, the empty task_create title, a coded outage staying `error`, the value-free setup-folder refusal with its guard, and REST's unit wording.
yannickmonney
added a commit
that referenced
this pull request
Sep 28, 2026
Merge 066d510 pulled the head of the still-open #3538 (fix/app-door-refusals-name-field) into this branch, so the squash of #3554 would have landed that PR's field-naming work under the reviewer title. This reverts the merge against its first parent, leaving the tree exactly as the reviewer fixes had it at 4d2cf36. #3538 lands on its own.
yannickmonney
added a commit
that referenced
this pull request
Sep 28, 2026
This was referenced Sep 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
T26 (TALE-84, with TALE-162 and TALE-103 as its duplicates): about 190 app-door routes answered a body their schema refused with a bare
{ error: 'invalid body' }. The dialog could only say "invalid body", and GlitchTip got the same opaqueAppError. On 0.5.55 the Products, Contacts and Data residency forms still let through values the server refuses.What changed
Every app door names the field (
services/platform/backend/lib/invalid-body-response.ts)invalidBodyResponse(c, zodError). That helper came in fix(platform): close the 2026-09-26 platform evaluation's S3 findings #3498; until now only products and contacts used it. The answer keeps theinvalid bodycode and adds afield: reasonmessage anddata.issues. The inlinedescribeIssuescopy in knowledge entries is gone too.invalidBodyIssuesResponse(c, issues)gives the same shape for a refusal that no schema raised: a share body or embedding body that is not JSON, or an automation save withoutdocument.content("must not be empty unless files are attached"). It used to show up as an unnamed "Invalid input" on the whole body.invalid-body-response.test.tsfails on any bareerror: 'invalid body'left underbackend/. A second case makes sure the scan can't pass without matching anything.The SPA shows the reason
invalidBodyReason(err)inlib/utils/backend-error.tsreturns the sentence of aninvalid bodyrefusal. For any other code it returns nothing, because another code'smessageis not a display contract.useBackendMutation/useBackendAction, plus the two task toasts that override them, now show that sentence instead of "Try again". Sending the same body again would only fail again.backendRefusalReasonthe way the product dialogs already did.Client validation now matches the server
@, Phone 50, Locale 20. Those caps moved next to the contact patterns inlib/shared/schemas/common.ts. The OpenAPI spec and the door read them from there too.utils/product-image-url-schema.ts). The parity test checks that the door refuses the same values. The error now shows under Image URL when that field is visible. Whether a host is public is still the door's decision, because it depends on deployment policy, and its reason is shown on the toast.invalid bodyon the result line. Save and Test now go through one check per section, which marks the fields and focuses the first one without sending anything. Required fields are judged after trimming, the way they are sent: a database made of spaces passed=== ''and came back as a 400. Every field has the door's length cap. The sources arePG_HOST_PATTERNandKNOWLEDGE_CONNECTION_PASSWORD_MAXin@tale/shared/schemas/knowledge, which replace the form's mirrored regex, andOBJECT_STORAGE_CONNECTION_MAXinlib/shared/schemas/object_storage.ts.products.edit.validation.imageUrlin en, de and fr. de-CH needs no override. The docs (platform/knowledge/structured-data,self-hosted/configuration/data-residency) now say what the forms check, in EN, DE and FR.Manual layer: added
KNOW-B13andDATA-B8, plus onereference/automation.mdrow that names the owning specs. I checked the IDs against #3524 (KNOW-F30) and #3527 (DATA-F12).Verification
origin/main, one at a time. Every new test failed and passed again with the fix:invalid-body-response.test.tsguard (withfeedback/routes.tsfrom main)contentpath)answerpath)useBackendMutation/useBackendAction2/2 (toast reason)invalidBodyReasonunit cases, and the image-URL parity cases.backend/lib,lib/utilsandscripts/openapi: 260 files, 2234 tests passed.app/features/{contacts,products,settings/data-residency,tasks/hooks}and both hooks: 263 passed.lib/i18n: 185 passed, with no report-mode finding on the new key.@tale/sharedknowledge.test.ts: 24 passed.services/docssuite: 166 passed.oxlint --type-awareandoxfmt --checkon every changed file: clean. A scopedtsc --noEmitover the changed files and their imports: clean.bun run lint:manualis ok, andcheck-guide.tsis OK on both touched suites.Left open
phone: ''. The door'sblankAsAbsentreads that as "not sent", so the old number stays behind a success toast. This is a silent no-op, not a 400, so it's out of scope here. The fix is to sendnulland widen the contract'sphone?: stringto allow it.contacts/productsand the cap, but the dialogs don't split the file or check its size first.invalid query(8 sites) and a few other codes (invalid email,invalid purpose,invalid status) still give no field. They were outside this task.