Skip to content

Skip and report unparseable files in the @context search codemod#5324

Merged
habdelra merged 2 commits into
mainfrom
worktree-cs-11708-deployed-usercard-search-migration
Jun 24, 2026
Merged

Skip and report unparseable files in the @context search codemod#5324
habdelra merged 2 commits into
mainfrom
worktree-cs-11708-deployed-usercard-search-migration

Conversation

@habdelra

Copy link
Copy Markdown
Contributor

The @context search codemod (packages/realm-server/scripts/codemod/context-search) called transformContextSearch per file with no error handling. A single module whose <template> the parser rejects threw out of the loop and aborted the entire run, masking every file after it — which is exactly what bites when sweeping a large body of card source.

This wraps the per-file transform in try/catch: on a parse throw the file is recorded in a new unparseable bucket and the sweep continues. Such modules can't be migrated mechanically (and don't compile as-is), so they're left untouched and surfaced in a new "Skipped unparseable file(s)" section alongside the existing migrated / hand-migration reports.

Verified on a two-file fixture (one clean card + one with a malformed template): the codemod migrates the clean file, reports the malformed one as skipped, and exits 0 instead of aborting.

🤖 Generated with Claude Code

https://claude.ai/code/session_01R4n4P6G1vFdSvSZaKkFK5f

The codemod called transformContextSearch per file with no error handling, so
a single module whose template the parser rejects threw out of the loop and
aborted the entire run — masking every file after it. Running the codemod over
a large body of card source is exactly where that bites.

Wrap the per-file transform in try/catch: on a parse throw, record the file in
a new "unparseable" bucket and continue. Such modules can't be migrated
mechanically (and don't compile as-is), so they're left untouched and listed in
a "Skipped unparseable file(s)" section at the end alongside the migrated and
hand-migration reports.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R4n4P6G1vFdSvSZaKkFK5f
@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Host Test Results

    1 files  ±0      1 suites  ±0   1h 41m 42s ⏱️ - 1m 32s
3 173 tests ±0  3 158 ✅ ±0  15 💤 ±0  0 ❌ ±0 
3 192 runs  ±0  3 177 ✅ ±0  15 💤 ±0  0 ❌ ±0 

Results for commit c2856f9. ± Comparison against earlier commit 5bf8304.

Realm Server Test Results

    1 files  ±0      1 suites  ±0   11m 10s ⏱️ -9s
1 727 tests ±0  1 727 ✅ ±0  0 💤 ±0  0 ❌ ±0 
1 820 runs  ±0  1 820 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit c2856f9. ± Comparison against earlier commit 5bf8304.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the resilience of the realm-server @context search codemod CLI by continuing the sweep when a single .gts file can’t be parsed, and reporting those files separately instead of aborting the entire run.

Changes:

  • Wraps transformContextSearch() per-file execution in try/catch so a parse failure doesn’t terminate the whole run.
  • Tracks skipped parse-failures in a new unparseable bucket and prints a dedicated “Skipped unparseable file(s)” report section.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/realm-server/scripts/codemod/context-search/run.ts Outdated
Address review feedback: `let result;` was an implicit `any` under
realm-server's `noImplicitAny` (and `scripts/` is in the tsconfig `include`,
so it would fail `lint:types`) — annotate it `TransformResult`. Also derive the
skip-path message via `err instanceof Error ? err.message : String(err)` so a
non-Error throw can't crash the report.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R4n4P6G1vFdSvSZaKkFK5f
@habdelra habdelra requested a review from a team June 23, 2026 22:43
@habdelra habdelra merged commit 54d8972 into main Jun 24, 2026
65 checks passed
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.

3 participants