Repository navigation
core: list the items that failed an all or any check - #145
Merged
Merged
Conversation
A failing all or any row showed the whole list it read, and the reader had to work out which items failed. Each such row now has failed_items: the items that made the check fail, in list order, each with its path, cause and value. With each, an inner list that's missing, null, not a list or empty is listed in place of its items. It's [] when the check passed or when the list itself can't be read, since the row's cause already says why. A check written wrong lists every item as ill_formed. Only the outer items of a nested check are listed, and rows of any_of, $applies and custom operators don't have it. Changes the report: rows of all and any checks, and their violations, have a new failed_items field. Closes #68 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When a ref couldn't be read, every item was listed with the ref's cause, including items that passed through another any_of option. An each of [] gave paths like xs[0]. with a trailing dot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #68.
A failing
alloranyrow shows the whole list it read, and the reader has to work out which items failed. Each such row now hasfailed_items.Example
Input:
{ "deployments": [ { "id": "dep-1", "deployed_by": "bob", "pull_requests": [ { "number": 7, "commits": [ { "sha": "a1", "author": "ann" } ] }, { "number": 8, "commits": [ { "sha": "b1", "author": "ann" }, { "sha": "b2", "author": "bob" } ] } ] } ] }Policy (DEV-0501 from #113):
The row, from this branch:
The rules
inputs, because it's a result rather than something ergo read.inputsdoesn't change, so the row still shows everything that was checked.path,causeandvalue. The path is written like a path in an expression, with the item's position added.each, an inner list that's missing,null, not a list or empty is listed in place of its items, for examplepull_requests[1].commitswith causeabsent.[]: when the check passed, and when the list itself can't be read, because the row's cause already says why.ill_formed. When a ref can't be read, every item gets the ref's cause.allandanychecks. Rows ofany_of,$appliesand custom operators don't.Changes the report: rows of
allandanychecks, and their violations, have a newfailed_itemsfield.One change from what we discussed: a passing
anygets[]rather than its failed items. Listing them meant checking every item, whereanyotherwise stops at the first item that passes, and that made those rows 3.5 times slower. With[], the rule is simply "items that made the check fail".Checks
opa check --strict,opa fmt --list,opa test(829/829),--strict-builtin-errorseval, Regal, the comment check and coverage: all clean.all/anychecks (usingeach,as, refs, substitutes and broken checks) through main and the branch:failed_itemsis identical to main.failed_itemsis on exactly theall/anyrows, is[]on every passing row, never lists a passing item, has no repeated paths, and matches in violations.failed_itemshas a top-level list that's missing, empty or not a list.allfails on a list holding just that item: 0 mismatches in 1,500 random checks (with refs that can't be read,any_of,nulls and wrong types). On the first version of this branch it found 33, from the bug fixed in 70f9fea.#35 and the playground (#124) should show
failed_itemsonce this lands.🤖 Generated with Claude Code