Feat/bch 1290#7
Conversation
…tData When the agent passes a tar.gz file path as policyPath, path-joining into a file returns ENOTDIR rather than ErrNotExist. Handle both as "not found" so the function does not propagate an error for non-directory candidates. Add TestLoadBundleRootData_TarGzBundle to document the remaining gap: the function silently returns empty defaults for tar.gz paths because it cannot read data.json from inside the archive. Policies relying on data.* will receive undefined references until tar.gz extraction support is added. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When the agent supplies a bundle as a tar.gz file path, LoadBundleRootData now detects the .tar.gz suffix and extracts data.json from the archive rather than attempting (and failing) filesystem path-joins into a file. The merge semantics are unchanged: bundle defaults are loaded first, operator-supplied overrides win on conflict. Tests: flip the gap test to assert correct loading; add TestLoadBundleRootData_TarGzBundleOverridesWin to confirm operator overrides still take precedence over archive defaults. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.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 (3)
💤 Files with no reviewable changes (2)
📝 WalkthroughWalkthrough
ChangesBundle loading and evaluator flow
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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 `@internal/eval_test.go`:
- Around line 33-65: Add unit tests around TestLoadBundleRootData to cover
tar.gz edge cases: create separate tests that (1) provide a tar.gz without a
data.json entry and assert LoadBundleRootData(bundlePath, overrides) returns
only the overrides and no error, (2) create a tar.gz with malformed JSON in
data.json and assert LoadBundleRootData returns an error, (3) include data.json
inside a subdirectory in the tar.gz and assert it is ignored (LoadBundleRootData
should return overrides/no error), and (4) create a corrupted tar.gz archive and
assert LoadBundleRootData returns an error; reuse the existing helpers like
writeTarGz, t.TempDir, bundlePath, and the LoadBundleRootData call and assert
behavior consistently with the existing tests.
- Around line 13-31: The deferred Close() calls in writeTarGz (f.Close(),
gw.Close(), tw.Close()) currently ignore errors; update the defers to check and
fail the test on close errors by capturing and handling each Close() return
(e.g., defer func(){ if err := tw.Close(); err != nil { t.Fatalf("tw.Close: %v",
err) } }()), similarly for gw and f) so any cleanup/write flush failures are
surfaced via t.Fatal/t.Fatalf; keep the existing t.Helper() and body handling
unchanged.
In `@internal/eval.go`:
- Around line 198-242: The deferred f.Close() and gr.Close() in
loadDataFromTarGz currently ignore returned errors; change loadDataFromTarGz to
use named return values (e.g., result map[string]interface{}, err error) and
replace the simple defers with deferred functions that call Close() and, if they
return a non-nil error and the named err is nil, assign or wrap that error into
the named err (so cleanup errors are surfaced), ensuring you still return the
proper merged result or overrides when appropriate.
🪄 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: 7ba0b8b0-ab25-4be8-a4e9-8372e51c27fa
📒 Files selected for processing (2)
internal/eval.gointernal/eval_test.go
rego.LoadBundle (used by the policy manager's GenerateResults) handles data.json loading from both directories and tar.gz bundles as a first- class feature. The plugin's LoadBundleRootData and loadDataFromTarGz were duplicating this work and failing to handle non-.tar.gz archive formats. Removing them reduces complexity and delegates bundle handling entirely to OPA. Operator-supplied policy_data overrides are still applied on top via the policy manager's writePolicyData after the bundle is loaded. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary by CodeRabbit
New Features
Tests