Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement: Output detailed index build errors when the number of errors is low #1038

Merged
merged 1 commit into from Jun 21, 2022

Conversation

haines
Copy link
Member

@haines haines commented Jun 21, 2022

Fixes #441

When no more than 5 errors occur during index build, or when debug logging is enabled, the full error details will now be printed instead of just the summary.

e.g. when starting server the output is now

2022-06-21T10:59:32.594+0100    ERROR   cerbos.index    Index build failed      {"missing": [{"importingFile":"policy.yaml","desc":"Import 'wat' not found"}]}
cerbos: error: failed to create store: failed to build index: missing imports=1, missing scopes=0, duplicate definitions=0, load failures=0

or if more than 5 errors occur

2022-06-21T11:38:49.002+0100    ERROR   cerbos.index    Index build failed      {"error": "too many errors; run `cerbos compile` to see a full list"}
cerbos: error: failed to create store: failed to build index: missing imports=3, missing scopes=0, duplicate definitions=0, load failures=3

@haines haines added the kind/enhancement New feature or request label Jun 21, 2022
@codecov
Copy link

codecov bot commented Jun 21, 2022

Codecov Report

Merging #1038 (2becb98) into main (95ceef5) will increase coverage by 0.22%.
The diff coverage is 70.10%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1038      +/-   ##
==========================================
+ Coverage   54.73%   54.96%   +0.22%     
==========================================
  Files         106      106              
  Lines       11806    11875      +69     
==========================================
+ Hits         6462     6527      +65     
- Misses       4796     4798       +2     
- Partials      548      550       +2     
Impacted Files Coverage Δ
internal/storage/index/index.go 38.61% <0.00%> (ø)
internal/engine/ast.go 77.71% <68.00%> (-1.15%) ⬇️
internal/storage/index/builder.go 84.46% <73.91%> (+1.41%) ⬆️
internal/server/tests.go 94.24% <0.00%> (-0.91%) ⬇️
internal/audit/local/badgerdb.go 63.17% <0.00%> (-0.64%) ⬇️
internal/engine/engine.go 63.84% <0.00%> (+0.76%) ⬆️
internal/engine/planner.go 76.97% <0.00%> (+1.16%) ⬆️
internal/compile/errors.go 55.55% <0.00%> (+15.87%) ⬆️

…rors is low

Signed-off-by: Andrew Haines <haines@cerbos.dev>
@haines haines force-pushed the detailed-index-build-errors branch from a4328ba to 2becb98 Compare June 21, 2022 10:51
Copy link
Contributor

@charithe charithe left a comment

Choose a reason for hiding this comment

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

🙌🏽

@haines haines merged commit 21ca214 into cerbos:main Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Output detailed index rebuild errors when the number of errors is low
2 participants