fix: prevents paanic on violations as array#86
Conversation
Signed-off-by: Gustavo Carvalho <gustavo.carvalho@container-solutions.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughPolicyManager.Execute now validates expression output types, normalizes ChangesPolicy Evaluation Error Handling
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@policy-manager/policy-manager_test.go`:
- Line 103: Replace the redundant explicit type declaration for the test
variable `data` with Go's short variable declaration so the type is inferred
from `make(map[string]interface{})`; locate the `data` declaration in
policy-manager_test.go (currently `var data map[string]interface{} =
make(map[string]interface{})`) and change it to use `:=` to satisfy ST1023 and
simplify the code.
In `@policy-manager/policy-manager.go`:
- Around line 183-190: The error message in the violations type-check block
(where you do val.(map[string]interface{}) into violationsMap) is misleading
because it assumes val is a slice; update the error to report the actual runtime
type or a more generic message: include fmt.Sprintf("got %T", val) (or change to
"expected violations to be a map/object") and keep the existing context
(result.Policy.Package, result.Policy.File) so the error reads accurately for
violationsMap, val, result.Policy.Package and result.Policy.File.
🪄 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 Plus
Run ID: 21ec03db-aa57-485f-83f5-a58c8e44165c
📒 Files selected for processing (2)
policy-manager/policy-manager.gopolicy-manager/policy-manager_test.go
Signed-off-by: Gustavo Carvalho <gustavo.carvalho@container-solutions.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@policy-manager/policy-manager.go`:
- Around line 187-189: The json.Unmarshal error returned for the violation
decode should be wrapped with context so failures are diagnosable; instead of
returning the raw err from json.Unmarshal([]byte(violation), viol) update the
error return to include identifying context (e.g., policy ID/name and
file/package) — reference the variables json.Unmarshal, violation and viol in
policy-manager.go and wrap the error with fmt.Errorf or errors.Wrapf (e.g.,
"failed to unmarshal violation for policy %s: %w", policyID, err) and add the
required import if missing.
🪄 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 Plus
Run ID: e0f700ff-2b2f-410f-8af9-d854f0c0de48
📒 Files selected for processing (2)
policy-manager/policy-manager.gopolicy-manager/policy-manager_test.go
fix: normalize violations Signed-off-by: Gustavo Carvalho <gustavo.carvalho@container-solutions.com>
|
Actionable comments posted: 0 |
Summary by CodeRabbit
Bug Fixes
Tests