Repository navigation
fix(agent-server): no exception text in API answers, snapshot path barrier and no-follow writes, dashboard error messages and no-follow read (abilityai/trinity-enterprise#1117) - #4293
Merged
Conversation
…up_dir (Abilityai/trinity-enterprise#1117) The snapshot endpoint resolved the caller's backup_dir before checking it. A normalised, separator-terminated comparison now runs first, in unresolved space, so the sibling-prefix case (../home2) cannot pass and '.' (the home itself) still does. The resolve() + relative_to check stays behind it for a link inside the home that points out of it. The X-Snapshot-Path header is computed against the resolved home, so a home reached through a link no longer raises after the write.
…ption text (Abilityai/trinity-enterprise#1117) A dashboard.yaml the validator could not walk (a list or string where a mapping belongs) surfaced as the raw AttributeError text, and an unreadable file as the OS error with its path. Each known failure now gets a fixed sentence the author can act on: not a mapping at the top level, a section or widget that is not a mapping, a file that could not be read (with the error class), or bytes that are not UTF-8. Anything else answers with the class name and is logged with its traceback, credential-scrubbed. The except yaml.YAMLError arm is removed: load_hardened_yaml converts every YAMLError into HardenedYamlError, so it could never run. Its import goes with it.
…Abilityai/trinity-enterprise#1117, #4284) The file routes (list, download, delete, update, mkdir) and the Claude Code, Gemini, Codex and headless task runtimes rendered an unforeseen exception's text into the 500 detail. That text can carry paths, subprocess output or a credential. The answer now keeps its existing prefix and names only the exception class; the text goes to the log with its traceback, passed through the credential sanitizer first. Codex's two TimeoutError arms are foreign by construction (every timeout the path owns is already a 504 HTTPException), so they now answer 'Codex execution timed out (<class>)', keeping 'timed out' for the backend's text checks. Messages the agent server writes itself are unchanged, including 'Permission bypass failed', which the backend's container-fault classifier matches.
…Error scrub and the two-slash backup_dir refusal (Abilityai/trinity-enterprise#1117, #4284) - Drive one files-route 500 through `agent_server.routers.files`, the way the agent server loads it, so `_log_failure`'s package branch runs under test. Every other files test loads the router by path. - The dashboard permission-denied test plants a credential in the PermissionError and checks the log record is scrubbed, so the OSError arm's sanitizer is held by a test. - Pin that a `backup_dir` with exactly two leading slashes is refused (POSIX normpath keeps them, so the barrier does not see the home prefix), and that one or three leading slashes stay accepted.
…bilityai/trinity-enterprise#1117, #4284) The class-only 500 detail let any UnicodeEncodeError or AttributeError pass these controls. Every changed site raises `from e`, so the original text is still on `__cause__`; checking it restores the controls' original specificity.
…lass (Abilityai/trinity-enterprise#1117, #4284) - agent-dashboard: the YAML parse answer is the hardened loader's named refusal (the old line/column form has been gone since #1965); add the not-a-mapping, unreadable, not-UTF-8 and unforeseen-failure answers. - file-browser: the unforeseen-failure 500s name the class; the OS error arm of the no-follow walk keeps its text. - skills-on-agent-start: the quoted update handler matches the code.
…117-s6-agent-server-error-text
obasilakis
approved these changes
Nov 6, 2026
obasilakis
left a comment
Contributor
There was a problem hiding this comment.
Reviewed (code review + /validate-pr, lane C). Approving.
- No consumer in backend, frontend, MCP or scheduler parses the removed error strings; status codes unchanged; server-side tracebacks still logged via
sanitize_textwithfrom e. Vendored mirrors untouched. - Snapshot barrier is correct (normpath both sides, trailing separator,
resolve()check retained). - Mutation: reverting the 7 agent_server files gives 27 failed / 20 passed; disabling only the snapshot
startswithbarrier gives 2 failed. Head 95/95 on 3.13.
Non-blocking:
tests/unit/test_ent1117_s6_agent_server_error_text.py:388fails on Python 3.11: before 3.12is_relative_tocallsrelative_to, so the patched raise fires in_refuse_outside_homeoutside the handler'stry. CI and images are 3.13. Raising from inside the walk (e.g. the per-entry stat) makes it version-independent.- Follow-up:
routers/snapshot.py:171-172writessnapshot.tar/files.txtwith symlink-followingwrite_bytes; a planted symlink inside an acceptedbackup_dirredirects the write.restorealready useswrite_bytes_nofollow. Nothing sendsbackup_dirtoday. - Follow-up: the backend proxy still returns
str(e)in its own 500s (services/agent_service/dashboard.py:322,files.py:631,769).
Merge-gate note: frontend-e2e skipped (no ui label); the changed strings surface in the dashboard and file browser.
…117-s6-agent-server-error-text
…llowing a link (Abilityai/trinity-enterprise#1117) The snapshot endpoint checked that `backup_dir` resolves inside the home, then wrote `snapshot.tar` and `files.txt` into it with plain writes, which follow a link at either name. Both files now go in through `files.write_bytes_nofollow` (ent#822), the writer the restore path in the same module already uses: the directories are walked and created one component at a time without following a link, and a link anywhere on the way, either file included, is a 403 `resolved_path_mismatch` instead of a write that lands elsewhere. Reusing a `backup_dir` still replaces its files. A `backup_dir` that is not a path string (a number, a boolean, a list, a mapping, or a string carrying a NUL) is now a 400 before any work is done, instead of a 500 from `os.path.join` or `resolve()`. An absent or empty `backup_dir` still means no disk copy.
…ver through a link (Abilityai/trinity-enterprise#1117) `GET /api/dashboard` read `/home/developer/dashboard.yaml` with `read_text()`, which follows a link. A link at that name made the endpoint parse another file, return it whole when it happened to be a valid dashboard, and quote its offending line in a `workspace_yaml_yaml_invalid` parse error otherwise. The file is now opened with O_NOFOLLOW and its modification time taken from the same descriptor. A link, live or dangling, gets one fixed answer ("it is a link, and links are not followed"), so neither another file's text nor whether a link's target exists reaches the caller. What is parsed is always the file at the fixed path, so a parse error keeps naming and quoting the offending line: that is the dashboard's own text, which the same caller receives whole on every successful read. The refusal codes are unchanged. A missing file, a non-UTF-8 file and an unreadable one keep their answers. The descriptor is closed when the open succeeds but the read cannot start (a directory at that name).
…me, and a FIFO test pins the non-blocking open (Abilityai/trinity-enterprise#1117) O_NOFOLLOW does not see a hard link, so a second name for another file at dashboard.yaml was still parsed, and a parse error quoted its line. The read now refuses a file whose link count is above 1 with the same fixed answer as a link, the rule Files already applies to hard-linked files below the owner tier (ent#820). A FIFO at the path is answered at once; a test pins the non-blocking open that keeps it from hanging the endpoint.
…k holds when the file is checked (Abilityai/trinity-enterprise#1117)
AndriiPasternak31
marked this pull request as ready for review
November 6, 2026 20:34
…ot the exception's (#4293) Mechanical, per the merge-train note on the PR. The TimeoutError arm in gemini_runtime.execute_headless returned str(e) in its 504 and logged it unscrubbed, the one runtime arm this PR's sweep missed. The answer is now built from timeout_seconds, which keeps the historical "Task execution timed out after N seconds" shape task_execution_service reads, and the log goes through sanitize_text. Part of Abilityai/trinity-enterprise#1117. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
|
merge-train (2026-11-06): one mechanical commit pushed to this branch, The validator found one runtime arm this sweep missed. In
Nothing else changed. This PR is on the current merge train. |
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.
Part of abilityai/trinity-enterprise#1117.
Also part of #4284.
Journey Impact: none: agent-server error answers name the exception class instead of its text; no user step changes
Problem
dashboard.yaml. It also carried anexcept yaml.YAMLErrorarm that can never run.dashboard.yamlwithread_text(), which follows a link. A link at that name, or a second name for another file, made it parse another file, and a parse error quotes the offending line.backup_dirbefore checking it. Therelative_tocheck was correct, but static analysis does not recognise a check that comes after the sink.snapshot.tarandfiles.txtintobackup_dirwith plain writes, which follow a link at either name and write through a hard link. Abackup_dirthat is not a string became a 500.Fix
startswithbarrier now runs beforeresolve(), comparing in unresolved space.resolve()+relative_tocheck is kept..and absolute paths inside the home are still accepted.../home2is refused.X-Snapshot-Pathheader is computed against the resolved home.snapshot.tarandfiles.txtgo in throughfiles.write_bytes_nofollow(ent#822), the writer the restore path in the same module already uses. The directories are walked and created one component at a time without following a link. A link anywhere on the way, either file included, is a 403resolved_path_mismatch, never a write that lands elsewhere.backup_dirthat is not a path string (a number, a boolean, a list, a mapping, a string with a NUL) is a 400 before any work is done. An absent or emptybackup_dirstill means no disk copy...is now applied lexically, before links are resolved. Example:deeplinks tohome/a/b, andoutlinks outside the home.deep/..now writes to the home itself; it used to write tohome/a/.deep/../..is now refused; it used to be accepted.out/../xis now accepted and writes tohome/x/; it used to be refused.resolve()+relative_tocheck still refuses any path whose links lead out of the home...cases.backup_dirwith exactly two leading slashes is now refused. For example//home/developer/x, whichresolve()used to collapse.normpathkeeps exactly two leading slashes, so the barrier does not see the home prefix.backup_diris now refused even when it stays in the home.backups -> home/elsewherewithbackup_dir: backups/run-1used to write intohome/elsewhere/run-1/; it is now a 403 and writes nothing.falseand0are now a 400. They used to be ignored like an absentbackup_dir.0644; an existing file keeps its mode.dashboard.yamlis opened withO_NOFOLLOW | O_NONBLOCK, and its link count and modification time are taken from the same descriptor.Failed to read dashboard.yaml: it is a link, and links are not followed. So neither another file's text nor whether a link's target exists reaches the caller.dashboard.yamla second name: a git checkout, a template copy and a local deploy all produce a file with one name (a local deploy's copy breaks a hard link carried in its archive).workspace_yaml_*codes. What is parsed is a file with no other name when it is checked, the same rule by which Files serves a file below the owner tier. So the quoted line is text the same caller receives whole on every successful read and through the Files routes. Dropping the quote would cost authors the pointer to their mistake and disclose nothing less.__cause__.Codex execution timed out (<class>).Permission bypass failed, which the backend's container-fault classifier matches. No backend classifier reads the new fixed strings; a test that runsfailure_classifier.pyon them pins this.Evidence
tests/unit/test_ent1117_s6_agent_server_error_text.pyhas 70 tests:sk-key and a credential in a URL. Each test checks that:., subdirectories, and absolute paths inside the home..and a subdirectory are accepted.snapshot.tarto a file outside the home, a link atfiles.txtto another file in the home, and a linked directory inside the home. Each link's target keeps its content.backup_dirand for a NUL; a reusedbackup_dirreplaces its files; nobackup_dirwrites nothing.test_1965_agent_server_safe_yaml.pyand bothtest_3408_*files;test_ent822_shared_folder_links.py,test_reset_preserve_state_*,test_agent_data_export.py,test_ent183_skill_packages.py;test_1265_*,test_2110_*,test_2198_*,test_ent479_*,test_ent730_*;test_ent820_*.Not covered
dashboard.yamldiscloses it outright...cases. The cases listed under Fix are described from a probe, not pinned by a test.files.txtis the refused link,snapshot.tarhas already been written into the same directory.OSErrorfrom opening a path component with that error's text (files.py:124): the errno message and the component the caller sent. This predates this PR.