-
-
Notifications
You must be signed in to change notification settings - Fork 14
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: Summarize "duplicate components" schema error #37
Comments
I'd like to give a try. |
If you look in
you can see how we colorize/truncate, etc. Ideally, if we could produce our own "ResultError" struct type(s), with only the data needed for output (and already pre-pre-processed) then we could create a means to have general "formatters" (interfaces) operate on that reliable data structure which could produce different output formats (see JSON error output format request in issue: #26). The "pre-processors" would be registered to curate (reduce, simplify, enhance, etc.) the data using the utilities "ResultError" structs (only called based upon field values in the result error struct) before being passed to the output formatters. The first "pre-processor" would handle (be triggered by) the |
Please see PR #40 as it introduces an error handling framework and shows how the |
Please see if we can use this to identify truly duplicate json (value) objects: https://github.com/mitchellh/hashstructure |
A library might be overkill. A very simple hash function for SBOM components is that component's JSON. seenComponents = map[string]int{}
for i, component := range ...
by, _ := json.Marshal(component)
strComponent := string(by)
nPrevious, seenBefore := seenComponents[strComponent]
if seenBefore {
... i and nPrevious are duplicates
}
seenBefore[strComponent] = i
} |
Extracted this feature request from issue #35
Look to create special "handlers" for common error types starting with "duplicates". For example, the handler could actually identify and extract the "duplicate" object (the first one) and then better format the error message to show the entire json object.
The text was updated successfully, but these errors were encountered: