chore: add AllowAnnotations bypass#4142
Conversation
📝 WalkthroughWalkthroughThis PR introduces an Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
openmeter/taxcode/service.go (1)
22-24: Consider documentingAllowAnnotationsintent inlineTiny doc comments here would make the internal-only bypass intent clearer and help prevent accidental broad use later.
💡 Suggested tweak
type inputOptions struct { + // AllowAnnotations bypasses system-managed guards for trusted/internal callers. + // Public API converters intentionally do not map this option. AllowAnnotations bool }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@openmeter/taxcode/service.go` around lines 22 - 24, Add a short doc comment above the inputOptions struct and its AllowAnnotations field explaining its intent as an internal-only bypass (e.g., to permit non-public annotation handling or testing), who may set it, and warnings against broad external use; update the comments for inputOptions and AllowAnnotations so future readers know it is not part of the public API and when it is safe to enable.openmeter/taxcode/service/taxcode_test.go (1)
73-80: Consider asserting post-delete state tooSmall improvement: after successful delete, fetch the tax code and assert not found. That makes this test resilient against future no-op delete behavior.
✅ Possible test strengthening
t.Run("DeleteIsByPassed", func(t *testing.T) { input := taxcode.DeleteTaxCodeInput{ NamespacedID: models.NamespacedID{Namespace: ns, ID: tc.ID}, } input.AllowAnnotations = true err := env.Service.DeleteTaxCode(t.Context(), input) require.NoError(t, err) + + _, err = env.Service.GetTaxCode(t.Context(), taxcode.GetTaxCodeInput{ + NamespacedID: models.NamespacedID{Namespace: ns, ID: tc.ID}, + }) + require.Error(t, err) + assert.True(t, taxcode.IsTaxCodeNotFoundError(err)) })As per coding guidelines:
**/*_test.go: Make sure the tests are comprehensive and cover the changes.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@openmeter/taxcode/service/taxcode_test.go` around lines 73 - 80, The test case "DeleteIsByPassed" currently only calls env.Service.DeleteTaxCode with a DeleteTaxCodeInput (setting AllowAnnotations) and asserts no error; enhance it by attempting to retrieve the deleted tax code afterwards and asserting it's not found: call the service read/get method (e.g., env.Service.GetTaxCode or equivalent read function that accepts models.NamespacedID or similar) using the same NamespacedID (models.NamespacedID{Namespace: ns, ID: tc.ID}) and assert that it returns a not-found error (or nil result and appropriate error) instead of a successful object, updating assertions accordingly to ensure delete had effect.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@openmeter/taxcode/service.go`:
- Around line 22-24: Add a short doc comment above the inputOptions struct and
its AllowAnnotations field explaining its intent as an internal-only bypass
(e.g., to permit non-public annotation handling or testing), who may set it, and
warnings against broad external use; update the comments for inputOptions and
AllowAnnotations so future readers know it is not part of the public API and
when it is safe to enable.
In `@openmeter/taxcode/service/taxcode_test.go`:
- Around line 73-80: The test case "DeleteIsByPassed" currently only calls
env.Service.DeleteTaxCode with a DeleteTaxCodeInput (setting AllowAnnotations)
and asserts no error; enhance it by attempting to retrieve the deleted tax code
afterwards and asserting it's not found: call the service read/get method (e.g.,
env.Service.GetTaxCode or equivalent read function that accepts
models.NamespacedID or similar) using the same NamespacedID
(models.NamespacedID{Namespace: ns, ID: tc.ID}) and assert that it returns a
not-found error (or nil result and appropriate error) instead of a successful
object, updating assertions accordingly to ensure delete had effect.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 76ea7455-1604-4fa8-b2f9-ef4063a5e73a
📒 Files selected for processing (4)
api/v3/handlers/taxcodes/convert.goopenmeter/taxcode/service.goopenmeter/taxcode/service/taxcode.goopenmeter/taxcode/service/taxcode_test.go
Summary by CodeRabbit