Skip to content

fix(agent): keep the attachment host out of the unreachable-attachment error - #5708

Merged
veryfront-code-auto-merge[bot] merged 3 commits into
mainfrom
fix/attachment-check-private-hostname
Dec 6, 2026
Merged

veryfront-code-auto-merge[bot] merged 3 commits into
mainfrom
fix/attachment-check-private-hostname

Conversation

@kojiwakayama

Copy link
Copy Markdown
Contributor

Problem

When an agent or chat turn carries an attachment whose URL points at a host the model provider cannot reach (loopback, private network, a local-network name, or the unspecified address), the turn fails with UnreachableAttachmentError. The error message quoted that host, for example "files.corp.internal" is a local-network name .... The message reaches the client stream body, so the sender saw an internal hostname or address that is not theirs to see.

Cause

In src/agent/runtime/attachment-reachability.ts, the loopback, private-network, local-network-name and unspecified-address reasons all put the hostname in quotes. The relative-URL reason repeated the raw input, so a host-only string such as //10.0.0.5/a.png was echoed too. UnreachableAttachmentError adds the reason to its message.

Change

  • The four host reasons are now fixed strings that name the kind of host ("the URL host is a loopback / private-network / local-network / unspecified address ...") and never the host itself.
  • The relative-URL reason is now "the URL is not an absolute URL" and no longer repeats the input.
  • describeUnreachableIPv4 and describeUnreachableIPv6 no longer take the unused hostname parameter.
  • The error still names the file, and attachmentUrl stays on the error object for server-side callers. No other callers needed changes: inline-file.ts only checks whether describeUnreachableAttachmentUrl returns undefined, and the message converter only throws the error.

Tests

In src/agent/runtime/attachment-reachability.test.ts:

  • New: "does not repeat the hostname in the reason". It covers loopback, private IPv4, IPv6 loopback, unspecified, unique-local, IPv4-mapped IPv6 (both the hex form URL produces and the dotted form the sender typed), .local, .internal with a trailing dot, and the host-only relative form.
  • New: "names the file without repeating a private hostname".
  • Changed: the test that asserted the message contains localhost now asserts it says loopback and does not contain localhost.

Results, all run with deno task test:file src/agent/runtime/attachment-reachability.test.ts:

  • Before the fix: FAILED, 16 steps passed, 5 failed. The failing steps were "does not repeat the hostname in the reason", "names the file and the reason" and "names the file without repeating a private hostname", for example Attachment "report.pdf" cannot be sent to the model: "files.corp.internal" is a local-network name ....
  • After the fix: ok, 1 passed (21 steps), 0 failed.
  • deno fmt --check and deno lint on the two changed files: clean.

Review

An independent review found no blocking issues. It suggested one optional test addition: URL rewrites [::ffff:192.168.1.4] to [::ffff:c0a8:104], so the mapped case only checked the hex form. The test now also checks the dotted 192.168.1.4 the sender typed (separate commit). No production code changed in that round.

Not verified

Left to CI: typecheck, the full unit and integration suites, and verify. I did not run tests/integration/agent/runtime-stream-error-origin.test.ts; its assertion checks only the message prefix Attachment "capacity.png" cannot be sent to the model, which is unchanged. I did not run src/provider/runtime-loader/private-network-file-url.test.ts or text-generation-runtime-message-converter.test.ts; a search found neither asserting on the changed reason text.

…t error

The agent and chat attachment check named the URL host in its reason, so a
loopback, private-network or local-network hostname appeared in the error
text sent back for the turn. The reason now says what kind of host it is
without repeating it, matching the provider runtime message. The relative
URL reason no longer echoes the input either. The URL itself stays on
UnreachableAttachmentError for server-side callers.
@kojiwakayama
kojiwakayama deployed to pull-request-auto-merge December 5, 2026 22:49 — with GitHub Actions Active
@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown

📦 Client bundle boundary

Entrypoint Modules Source size Server leaks
src/index.client.ts 66 371 KiB ✅ 0
src/react/components/Head.tsx 5 74 KiB ✅ 0
src/react/router/index.tsx 5 74 KiB ✅ 0
src/react/context/index.tsx 5 74 KiB ✅ 0
src/react/fonts/index.ts 6 81 KiB ✅ 0
src/react/components/ui/index.ts 111 720 KiB ✅ 0
src/react/components/ui/adapter/contract.ts 1 18 KiB ✅ 0
src/react/components/ui/icons/index.ts 3 17 KiB ✅ 0
src/chat/index.ts 305 2059 KiB ✅ 0
src/chat/ag-ui.ts 61 464 KiB ✅ 0
src/chat/protocol.ts 1 11 KiB ✅ 0
src/chat/types.ts 46 248 KiB ✅ 0
src/chat/message-prep.ts 80 588 KiB ✅ 0
src/markdown/index.ts 6 30 KiB ✅ 0
src/mdx/index.ts 2 2 KiB ✅ 0
src/agent/identity-contracts.ts 1 3 KiB ✅ 0
src/schemas/index.ts 43 222 KiB ✅ 0
src/platform/env.ts 5 55 KiB ✅ 0
src/workflow/claude-code/react/index.ts 9 91 KiB ✅ 0
src/events/index.ts 37 631 KiB ✅ 0
src/events/ag-ui/public.ts 36 624 KiB ✅ 0
src/run-events/index.ts 54 323 KiB ✅ 0

A server module in a client graph aborts hydration in the browser. New leaks fail CI; known leaks are tracked in scripts/lint/client-bundle-baseline.json to burn down.

@kojiwakayama
kojiwakayama marked this pull request as ready for review December 5, 2026 23:30
@kojiwakayama
kojiwakayama deployed to pull-request-auto-merge December 5, 2026 23:30 — with GitHub Actions Active
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-05T23:48:40.918071Z 0089839 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c28d0eaae5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 0089839acd

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@codecov

codecov Bot commented Dec 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@veryfront-code-auto-merge
veryfront-code-auto-merge Bot added this pull request to the merge queue Dec 6, 2026
@sonarqubecloud

sonarqubecloud Bot commented Dec 6, 2026

Copy link
Copy Markdown

Merged via the queue into main with commit e751f59 Dec 6, 2026
867 of 870 checks passed
@veryfront-code-auto-merge
veryfront-code-auto-merge Bot deleted the fix/attachment-check-private-hostname branch December 6, 2026 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant