Skip to content

Report failed item insertions instead of showing false success - #121

Merged
MarkSackerberg merged 2 commits into
mainfrom
fix/cm-insert-validation
Apr 23, 2026
Merged

Report failed item insertions instead of showing false success#121
MarkSackerberg merged 2 commits into
mainfrom
fix/cm-insert-validation

Conversation

@MarkSackerberg

Copy link
Copy Markdown
Contributor

cm insert and the wizard now count loaded vs failed items after insertion and warn when some items failed, with instructions to retry. Previously showed "Asset cache updated successfully" even when transactions failed (e.g. from RPC rate limiting).

cm insert and the wizard now count loaded vs failed items after
insertion and warn when some items failed, with instructions to
retry. Previously showed "Asset cache updated successfully" even
when transactions failed (e.g. from RPC rate limiting).
@coderabbitai

coderabbitai Bot commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@MarkSackerberg has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 54 minutes and 48 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 54 minutes and 48 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2124037d-5189-4a73-a634-87cbcbf9cb88

📥 Commits

Reviewing files that changed from the base of the PR and between f49634a and 45d1e80.

📒 Files selected for processing (5)
  • src/commands/cm/create.ts
  • src/commands/cm/insert.ts
  • src/lib/cm/cm-utils.ts
  • test/commands/cm/cm.insert.test.ts
  • test/runCli.ts

Walkthrough

The changes add detailed insert outcome reporting to the cm create and cm insert commands, computing per-item success/failure counts and displaying appropriate messaging with retry instructions. Test assertions are updated to match the new success message text.

Changes

Cohort / File(s) Summary
Command outcome reporting
src/commands/cm/create.ts, src/commands/cm/insert.ts
Both commands now track and report per-item insert outcomes by filtering asset items on loaded status. Compute failed/total counts and log warnings with retry instructions when failures occur. Updated result objects to include totalItems, itemsInserted (loaded count), and itemsFailed.
Test assertions and coverage
test/commands/cm/cm.full.test.ts, test/commands/cm/cm.insert.test.ts
Updated success assertions from "Asset cache updated successfully" to "items inserted successfully". Added new test case forcing partial insert failure by marking items as unloaded and using invalid candy machine ID, verifying warning logs and retry command instructions appear in output.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title accurately summarizes the main change: reporting failed item insertions instead of showing false success.
Description check ✅ Passed The pull request description clearly explains the changes: counting loaded vs failed items and warning when some items failed, addressing the prior issue of false success messages.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/cm-insert-validation

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/commands/cm/create.ts`:
- Around line 229-237: Extract the duplicated failed-insert counting and
messaging into a shared helper (e.g., functions named
summarizeAssetCache(assetCache) -> { totalItems, loadedItems, failedItems }
and/or reportFailedInsertions(assetCache, candyMachineDir, logger)) and replace
the block that inspects insertItemsRes.assetCache.assetItems in create.ts with
calls to that helper; update the insert.ts usage to call the same helper so both
commands stay in sync, and standardize the retry message wording to "... again
to retry failed items." across both callers.

In `@src/commands/cm/insert.ts`:
- Around line 58-70: When failedItems > 0 in the insert command, the code
currently logs a warning then returns a success-like result; update the failure
path in the method containing the shown block (where this.log, this.logSuccess
and the returned object are used) to signal a non-zero exit: after logging the
warning call this.error(...) with a clear message (or set process.exitCode = 1)
and then return or throw so callers/CI receive a failing exit code instead of 0;
ensure the returned object or thrown error still includes candyMachineId,
totalItems, itemsInserted and itemsFailed if needed for diagnostics.

In `@test/commands/cm/cm.insert.test.ts`:
- Line 55: The assertion hardcodes the default asset count string "All 50 items
inserted successfully" from create-test-cm, which is brittle; either make the
test supply the explicit flag by adding --assets=50 to the earlier
create-test-cm invocation (so the count is deterministic), or relax the
expectation by changing the assertion on stdout for
expect(stdout).to.include(...) to a substring like 'items inserted successfully'
to avoid depending on the numeric default.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7ca424d0-6ef7-401f-b194-03697d2f1cca

📥 Commits

Reviewing files that changed from the base of the PR and between e95d0c4 and f49634a.

📒 Files selected for processing (4)
  • src/commands/cm/create.ts
  • src/commands/cm/insert.ts
  • test/commands/cm/cm.full.test.ts
  • test/commands/cm/cm.insert.test.ts

Comment thread src/commands/cm/create.ts
Comment thread src/commands/cm/insert.ts
Comment thread test/commands/cm/cm.insert.test.ts
- Extract summarizeAssetCache helper in cm-utils and use it from both
  cm create and cm insert so the counting logic stays in sync
- Align retry wording across both callers ("again to retry failed items")
- Signal partial failure with process.exitCode = 1 so CI/scripts can
  detect failed inserts
- Pass --assets=50 explicitly in the insert test so the assertion does
  not depend on create-test-cm defaults
- Include stdout in runCli failure error so tests that inspect the
  error message after a non-zero exit can still see warning output
@MarkSackerberg
MarkSackerberg merged commit 71c73d4 into main Apr 23, 2026
4 of 5 checks passed
@MarkSackerberg
MarkSackerberg deleted the fix/cm-insert-validation branch April 23, 2026 13:58
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.

2 participants