fix(marketplace): guard fetch-source against missing sourceUrl/sha - #1691
Conversation
📝 WalkthroughWalkthroughThe marketplace source-fetch script makes ChangesOptional source-fetch fields and validation
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Review SummaryVerdict: minor-fixes-needed This PR adds a guard to Blocking issues(none — no CRITICAL findings) Suggested fixes
Minor / nice-to-have
Compliments
Reviewed via maintainer-review-pr workflow (Pi/Minimax). Aspects run: code-review, error-handling, test-coverage, comment-quality. |
|
@$gai095481 related to #1326 — overlapping area or partial fix. |
|
@$gai095481 related to #1720 — overlapping area or partial fix. |
|
@$gai095481 related to #1489 — overlapping area or partial fix. |
|
@$gai095481 related to #1578 — overlapping area or partial fix. |
|
@$gai095481 related to #1326 — overlapping area or partial fix. |
|
@$gai095481 related to #1720 — overlapping area or partial fix. |
|
@$gai095481 related to #1489 — overlapping area or partial fix. |
|
@$gai095481 related to #1578 — overlapping area or partial fix. |
|
Hi @gai095481 — thanks for opening this PR. This repository uses a PR template at
Could you fill those out (even briefly)? The template helps reviewers understand scope, risk, and rollback — it speeds up review significantly. If a section genuinely doesn't apply, just write "N/A" in it rather than leaving it blank. |
Review SummaryVerdict: minor-fixes-needed Nice, focused bugfix — the missing-field guard in Blocking issues
Suggested fixes
Minor / nice-to-have
ComplimentsThe guard is consistent with the script's existing error contract, and the inline comment grounding the WHY in a concrete scenario ("PR without a marketplace entry") is the kind of comment the project's style guide is asking for — keep doing that. Reviewed via maintainer-review-pr workflow (Pi/Minimax). Aspects run: code-review, error-handling, test-coverage, comment-quality. docs-impact skipped (no docs/README changes in PR). |
The marketplace-fetch-source script crashes with TypeError when sourceUrl
is undefined, which happens when the CI workflow runs on PRs that don't
add a marketplace entry (no sourceUrl in entry.json).
- Make sourceUrl and sha optional in MarketplaceEntry interface
- Add early return with exit(0) when either field is missing
- Output empty {files, errors} result so downstream AI review node
can proceed without source files instead of killing the workflow
Fixes the Run marketplace auto-review CI failure on PRs coleam00#1685 and coleam00#1689.
- Add marketplace-fetch-source.test.ts covering all guard paths: - missing sourceUrl only (stderr mentions sourceUrl, exit 0) - missing sha only (stderr mentions sha, exit 0) - missing both (stderr mentions both, exit 0) - both present (guard does not trigger, gh api errors expected) - missing entry.json (exit 1) - Trim inline comment to 2 lines per review feedback
Replace the network-dependent 'both fields present' case with an intentionally unrecognized sourceUrl so the script stops deterministically at URL validation instead of reaching gh api. Trim WHAT-restating comments per review and add the missing trailing newline.
6cf9075 to
62dcb7a
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.archon/scripts/__tests__/marketplace-fetch-source.test.ts (1)
17-17: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAvoid pre-creating the
source/directory in the test helper.The PR reviewer noted that the script itself creates an empty
source/directory before returning. By pre-creating it here in the test helper, the tests will silently pass even if the script fails to create this directory.Consider removing this line and instead adding assertions in the missing-field tests to verify that the
source/directory was successfully created by the script.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.archon/scripts/__tests__/marketplace-fetch-source.test.ts at line 17, Remove the pre-creation of the source directory from the test helper setup. Update the missing-field tests around the marketplace fetch script invocation to assert that the script itself creates the source directory, while preserving the existing test behavior and cleanup.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.archon/scripts/__tests__/marketplace-fetch-source.test.ts:
- Line 76: Update the negative assertion in the marketplace fetch test to check
for the updated guard wording, such as “needed for fetching,” instead of the
obsolete “missing required field” text. Keep the assertion tied to the exact
message emitted by the script’s validation guard so it still detects an
incorrectly triggered guard.
---
Nitpick comments:
In @.archon/scripts/__tests__/marketplace-fetch-source.test.ts:
- Line 17: Remove the pre-creation of the source directory from the test helper
setup. Update the missing-field tests around the marketplace fetch script
invocation to assert that the script itself creates the source directory, while
preserving the existing test behavior and cleanup.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7300dae9-883e-4c54-bbed-9ad665428377
📒 Files selected for processing (2)
.archon/scripts/__tests__/marketplace-fetch-source.test.ts.archon/scripts/marketplace-fetch-source.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- .archon/scripts/marketplace-fetch-source.ts
| sourceUrl: 'https://example.com/not-a-github-url', | ||
| sha: 'abc123def456', | ||
| }); | ||
| expect(stderr).not.toContain('missing required field'); |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Update the negative assertion to match the updated guard message.
The PR reviewer suggested changing the error wording from "required" to "needed for fetching". If the script's error message was updated accordingly, this negative assertion (not.toContain('missing required field')) will pass vacuously even if the guard is mistakenly triggered, hiding potential bugs.
Ensure this assertion reflects the exact string emitted by the updated guard (e.g., 'needed for fetching').
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.archon/scripts/__tests__/marketplace-fetch-source.test.ts at line 76,
Update the negative assertion in the marketplace fetch test to check for the
updated guard wording, such as “needed for fetching,” instead of the obsolete
“missing required field” text. Keep the assertion tied to the exact message
emitted by the script’s validation guard so it still detects an incorrectly
triggered guard.
Summary
The
marketplace-fetch-sourcescript crashes withTypeError: undefined is not an object (evaluating 'sourceUrl.match')whensourceUrlis undefined inentry.json. This happens on PRs that don't add a marketplace entry (nosourceUrlfield), causing the marketplace-auto-review CI check to fail on every such PR.Problem
fetch-sourcedestructures{ sourceUrl, sha }fromentry.jsonwithout null checksmarketplace.ts, thesourceUrlfield isundefined.match()onundefinedthrowsTypeError, killing the entire workflowWhat Changed
sourceUrlandshaoptional in theMarketplaceEntryinterface{ files, errors }result, then exit 0Validation
Note: wiring
.archon/scriptstests intobun run test/CI lands separately via #2147 — not duplicated here.exit(0)— no behavioral change whensourceUrlandshaare present (the happy path for marketplace entries)Security Impact
None. This is a defensive null check that prevents a crash; no new data flows or permissions are introduced.
Compatibility
Fully backward compatible. Existing marketplace entries with valid
sourceUrl/shaare unaffected.Rollback Plan
Revert this commit to restore the previous behavior (crash on missing fields).
Blast Radius
Single script:
.archon/scripts/marketplace-fetch-source.ts. Only affects thefetch-sourcenode inmarketplace-pr-review-and-merge.yaml. No other workflows or scripts are impacted.Risks & Mitigations
bundle-sourcenode (from PR fix(marketplace-auto-review): feed actual workflow source to AI reviewer #1689) already handles surfacing available source content to the AI reviewer. When source files are empty, the reviewer works with what it has — this is preferable to the entire CI check crashing.Summary by CodeRabbit