Skip to content

fix(core): break filesystem/search runtime import cycle - #49298

Closed
tstachl wants to merge 1 commit into
anomalyco:devfrom
tstachl:fix-fs-import-cycle
Closed

tstachl wants to merge 1 commit into
anomalyco:devfrom
tstachl:fix-fs-import-cycle

Conversation

@tstachl

@tstachl tstachl commented Sep 16, 2026

Copy link
Copy Markdown

Every prompt on the nixpkgs build (1.18.30, 1.18.31) dies before the model call with TypeError: undefined is not an object (evaluating 'node.name'), surfaced as 'Unexpected server error' (ref err_* in server logs).

Root cause: packages/core/src/filesystem.ts captures FileSystemSearch.node in its layer deps at module scope, while filesystem/search.ts imports ../filesystem at runtime. When the bundle evaluates search.ts first, the namespace is still uninitialized, so the dep is captured as undefined and the layer-tree walk (walk/recur -> resolve -> node.name) throws on first use via Agent.defaultInfo. (Minified stacks misattribute it to SystemPrompt.environment; an unminified build shows the true Agent.state path.)

Fix: make the search.ts import type-only and take the Entry/Match values straight from @opencode-ai/schema/filesystem (the same objects core re-exports). No behavior change; verified a bundle built from the patched source answers prompts again.

packages/core/src/filesystem.ts captures FileSystemSearch.node in its
layer deps at module scope, while filesystem/search.ts imports
../filesystem at runtime. When the bundle evaluates search.ts first,
FileSystemSearch.node is still undefined, so every prompt dies in the
layer-tree walk (recur -> resolve -> node.name on undefined) and
surfaces as 'Unexpected server error'.

Make the search.ts import type-only and take the Entry/Match values
straight from @opencode-ai/schema/filesystem (the same objects core
re-exports), removing the runtime edge.
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Sep 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found:

Related PRs that may be relevant context:

Recommendation: Check if PR #48877 was closed or if this is a reopened/revised attempt at the same fix. If PR #48877 is still open, this is likely a duplicate that should reference or potentially be combined with that PR.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Sep 16, 2026
@github-actions github-actions Bot closed this Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant