feat(cli): Print report on failure#3365
Conversation
|
Warning Rate limit exceeded
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 18 minutes and 39 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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 configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughWrites an updated namespaced-policy summary on commit failure and refactors migration summary logic to classify creation outcomes into Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI
participant Executor
participant Migrator
participant SummaryRenderer
participant Console
User->>CLI: run migrate --commit
CLI->>Executor: Execute(plan)
Executor->>Migrator: run target executions
Migrator-->>Executor: ExecutionResults (per-target)
Executor-->>CLI: error or success + ExecutionResults
CLI->>SummaryRenderer: writeNamespacedPolicySummary(plan, commit=true, result)
SummaryRenderer->>Console: render summary (created, to_create, failed, other counts)
alt Executor returned error
CLI->>Console: cli.ExitWithError("could not execute namespaced-policy commit", err)
else success
CLI->>Console: exit 0
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly improves the user experience of the CLI by introducing comprehensive failure reporting for namespaced policy commit operations. Instead of a generic error message, users will now receive a detailed summary of the migration plan, highlighting which items were successfully created, which are still pending, and which specifically failed, along with their reasons. This provides crucial visibility into the partial success or failure of complex migrations, enabling quicker debugging and resolution. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. When code does fail to run, A summary, clearly spun, Shows what was done, And what's undone, Bringing clarity, second to none. Footnotes
|
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
There was a problem hiding this comment.
Code Review
This pull request enhances the namespaced policy migration summary by introducing detailed tracking for failed and pending creation states. It refactors the summary logic to distinguish between items that were successfully created, those that failed, and those that are still pending during a dry-run. Key changes include updating the status count structures, adding execution state classification, and improving the rendered output to include failure details. Feedback suggests refactoring duplicated logic across summarization functions, removing dead code in recordTargetStatus, and simplifying conditional checks in classifyCreateExecution.
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@otdfctl/docs/man/migrate/namespaced-policy.md`:
- Around line 63-65: The second sentence in "Other information" is a fragment
and mixes singular/plural; replace it with a complete, consistent sentence. For
the scope example (strings 'subject-mappings', 'actions',
'subject-condition-sets'), reword to something like: "For example, if you
specify the scope 'subject-mappings', the migration will also include the
dependent scopes 'actions' and 'subject-condition-sets'." Ensure quotes around
the scope names and match pluralization.
- Around line 37-51: The ordered list is broken because the sublist (the Actions
/ Subject-Condition-Sets / Subject-Mappings / Obligation-Triggers /
Registered-Resources items) is not indented, so move that bullet list to be
nested under the parent ordered item (indent each sublist line by four spaces or
one tab) so it remains part of item 2; also fix the comma splice in the sentence
starting "Use `--interactive` mode when migrating policy, this will give you…"
by splitting into two sentences (e.g., "Use `--interactive` mode when migrating
policy. This will give you the best chance…") or replacing the comma with a
semicolon.
In `@otdfctl/migrations/namespacedpolicy/summary.go`:
- Around line 169-180: The current code eagerly constructs all five formatted
lines for every target before calling appendTargetStatusSummary, causing
redundant allocations and repeated styles.Info().Render calls; change to lazy
factories by replacing targetSummaryLines (used at call site in
appendTargetStatusSummary) with a struct of functions (e.g., created, toCreate,
failed, skipped, unresolved func() string) or similar lazy closures so only the
matching branch in appendTargetStatusSummary invokes its factory; update the
call site where targetSummaryLines is built (the block passing
formatCreatedLine, formatFailedLine, etc.) to pass zero-arg functions that call
those format helpers, and adjust appendTargetStatusSummary
signature/implementation to call the appropriate factory instead of using
prebuilt strings.
In `@otdfctl/scripts/populate-legacy-obligation-triggers.sh`:
- Around line 1-255: The script currently places the DB password in the process
list by passing PGPASSWORD via env when DATABASE_URL is not set (see usage of
OPENTDF_DB_PASSWORD and the psql_env/env invocation); either avoid exporting
PGPASSWORD or mitigate this by creating a secure temporary .pgpass file (set
restrictive permissions, write host:port:database:user:password, set PGPASSFILE
to it) and use that for psql, or at minimum add a short header comment
documenting the operational risk of PGPASSWORD appearing in process listings and
recommending use of DATABASE_URL or a .pgpass file for production/shared-host
runs.
🪄 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: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: b9d9df1c-4569-45fa-bb3c-9dc87a43a6f9
📒 Files selected for processing (3)
otdfctl/docs/man/migrate/namespaced-policy.mdotdfctl/migrations/namespacedpolicy/summary.gootdfctl/scripts/populate-legacy-obligation-triggers.sh
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@otdfctl/migrations/namespacedpolicy/registered_resources_execute.go`:
- Around line 61-63: Remove the inline "? We should remove this right? As we
don't currently check. We must keep the call to existingRegisteredResource as it
is required for the reuse path: the call that assigns created,
hasExistingParent, err := e.existingRegisteredResource(ctx, target) should
remain and you should simply delete the TODO/question comment. This call relies
on target.ExistingID (set by the planner in finalize_plan) to detect and load an
existing parent RR and skip unconditional creation (enabling per-value
reconciliation), so do not remove or short-circuit the
existingRegisteredResource invocation.
🪄 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: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 4b23dde0-fe16-422f-afd9-de68b6c0fe79
📒 Files selected for processing (2)
otdfctl/migrations/namespacedpolicy/registered_resources_execute.gootdfctl/migrations/namespacedpolicy/summary.go
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
|
🤖 I have created a release *beep* *boop* --- ## [0.32.0](opentdf/platform@otdfctl/v0.31.0...otdfctl/v0.32.0) (2026-05-19) ### Features * **cli:** Add better unit testing. ([opentdf#3378](opentdf#3378)) ([3ad33dc](opentdf@3ad33dc)) * **cli:** Add interactive review for prune plans ([opentdf#3421](opentdf#3421)) ([c11680b](opentdf@c11680b)) * **cli:** Add prune confirmation. ([opentdf#3469](opentdf#3469)) ([c6d47ec](opentdf@c6d47ec)) * **cli:** Add prune planner. ([opentdf#3411](opentdf#3411)) ([3e294e6](opentdf@3e294e6)) * **cli:** Add prune summary information ([opentdf#3456](opentdf#3456)) ([c900c53](opentdf@c900c53)) * **cli:** add sensitive flag annotation to DocFlag ([opentdf#3457](opentdf#3457)) ([98f48d2](opentdf@98f48d2)) * **cli:** Confirm and execute pruning of legacy objects ([opentdf#3458](opentdf#3458)) ([24c09dd](opentdf@24c09dd)) * **cli:** Print report on failure ([opentdf#3365](opentdf#3365)) ([05a4473](opentdf@05a4473)) * **cli:** Sort parameters. ([opentdf#3478](opentdf#3478)) ([73ad878](opentdf@73ad878)) * **policy:** Add FQN to RegisteredResourceValues ([opentdf#3446](opentdf#3446)) ([3199583](opentdf@3199583)) * **policy:** Add resource mapping group FQNs ([opentdf#3447](opentdf#3447)) ([6a0b3c6](opentdf@6a0b3c6)) ### Bug Fixes * **cli:** Prune was not classifying multi-namespaced RRs properly. ([opentdf#3488](opentdf#3488)) ([eae8645](opentdf@eae8645)) * **cli:** support json profile output ([opentdf#3448](opentdf#3448)) ([61f194c](opentdf@61f194c)) * **deps:** bump github.com/opentdf/platform/lib/identifier from 0.3.0 to 0.4.0 in /otdfctl ([opentdf#3367](opentdf#3367)) ([aa23179](opentdf@aa23179)) * **deps:** bump github.com/opentdf/platform/protocol/go from 0.27.0 to 0.28.0 in /otdfctl ([opentdf#3419](opentdf#3419)) ([c80374f](opentdf@c80374f)) * **deps:** bump github.com/opentdf/platform/sdk from 0.16.0 to 0.17.0 in /otdfctl ([opentdf#3397](opentdf#3397)) ([bb9fcd6](opentdf@bb9fcd6)) * **deps:** bump go.opentelemetry.io/otel from 1.40.0 to 1.41.0 in /otdfctl ([opentdf#3400](opentdf#3400)) ([5631c37](opentdf@5631c37)) * **deps:** bump module protocol/go to v0.30.0 throughout ([opentdf#3459](opentdf#3459)) ([8eaa502](opentdf@8eaa502)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: opentdf-automation[bot] <149537512+opentdf-automation[bot]@users.noreply.github.com> Co-authored-by: Chris Reed <87077975+c-r33d@users.noreply.github.com>
Proposed Changes
1.) Print the progressed plan on any runtime errors during commit.
2.) Add additional documentation to the
migrate namespaced-policycommandTesting Instructions
Summary by CodeRabbit
Bug Fixes
New Features
Documentation
Tests
Chores