Skip to content

feat: dig template function + BoltDB empty-root fix + skip-on-error#140

Merged
jamestexas merged 3 commits intomainfrom
feat/dig-boltdb-fixes
Mar 27, 2026
Merged

feat: dig template function + BoltDB empty-root fix + skip-on-error#140
jamestexas merged 3 commits intomainfrom
feat/dig-boltdb-fixes

Conversation

@jamestexas
Copy link
Copy Markdown
Contributor

Enables mixed-format Trivy projection (vunnel + OSV) via dig template function, fixes BoltDB materializer for empty root nodes and special characters in node names, and adds skip-on-error for graceful mixed-format handling. 7 new tests.

dig: safely navigate nested maps/slices by dot-separated path.
Returns "" if any intermediate key is missing, nil, or out of bounds.
Supports map keys and integer indices for slices.
Enables mixed-format schemas (e.g. vunnel + OSV in one projection).

  {{dig "item.Vulnerability.NamespaceName" .}} → "alpine:3.18" or ""
  {{dig "item.affected.0.package.ecosystem" .}} → "AlmaLinux:8" or ""

BoltDB materializer:
- Rewritten to use parent_id tree traversal (not path splitting on /)
- Handles node names containing slashes, parens, spaces correctly
- Empty-named root nodes are transparent (children become top-level buckets)
- Self-referencing nodes (id=="" parent_id=="") don't cause infinite recursion
- 7 tests including empty-root and existing tests

Skip-on-error: template render failures in node/file names log WARN and
skip the record instead of aborting the entire ingestion. Enables schemas
that handle mixed-format data sources gracefully.

Build: Taskfile.yml now includes -tags boltdb by default.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves ingestion/materialization robustness for mixed-format vulnerability data by adding a safe dig template helper, making ingestion optionally tolerant of template render failures, and fixing BoltDB materialization edge cases around empty-root nodes and special characters in node names.

Changes:

  • Add dig(path, obj) template function for safe traversal of nested maps/slices in templates.
  • Update ingestion to skip (instead of error) when a node name template fails to render, enabling mixed-shape records to coexist.
  • Rework BoltDB materializer traversal to use parent_id + name (not path splitting) and add coverage for empty-root node behavior; enable boltdb tag in task build.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
internal/materialize/boltdb.go Replaces path-splitting with parent/child traversal; adds empty-root handling and recursive materialization.
internal/materialize/boltdb_test.go Adds a regression test for empty-root node schemas using an on-disk SQLite fixture.
internal/ingest/engine.go Adds dig template func and changes name-render failures to warn+skip for mixed-format handling.
internal/ingest/dig_test.go Adds unit tests covering dig behavior across missing keys, arrays, nils, and composition with other funcs.
Taskfile.yml Builds with -tags boltdb by default.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/materialize/boltdb.go Outdated
Comment thread Taskfile.yml
Comment thread internal/ingest/engine.go
Comment thread internal/ingest/engine.go
Comment thread internal/ingest/engine.go
Comment thread internal/materialize/boltdb.go
Comment thread internal/materialize/boltdb.go
Comment thread internal/materialize/boltdb.go
- Remove redundant `any` type annotation in dig func (lint fix)
- Add visited set to materializeBoltChildren for cycle detection
- Restrict transparent root passthrough to actual root (parentBucket==nil)
- Guard empty path components in dig ("a..b" no longer returns index 0)
- Add -tags boltdb to test task so boltdb tests run in CI
- Document _root bucket behavior in BoltDBMaterializer doc comment
@jamestexas jamestexas enabled auto-merge (squash) March 27, 2026 20:45
@jamestexas jamestexas merged commit dc0dc08 into main Mar 27, 2026
13 checks passed
@jamestexas jamestexas deleted the feat/dig-boltdb-fixes branch March 27, 2026 20:47
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