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

Is there a better way to give hints about parse/format errors? #1436

Open
dexhorthy opened this issue Jan 29, 2024 · 2 comments
Open

Is there a better way to give hints about parse/format errors? #1436

dexhorthy opened this issue Jan 29, 2024 · 2 comments

Comments

@dexhorthy
Copy link
Member

dexhorthy commented Jan 29, 2024

Describe the rationale for the suggested feature.

Right now, simple YAML errors like missing an indent result in nonexistent analyzer errors.

Screenshot 2024-01-28 at 6 25 37 PM

Describe the feature

I picked up some code and ran support-bundle, only to find that It output nonexistent analyzer

The code in the file is

        - distribution:
          outcomes:
            - pass:
                when: "== kurl"
                message: kurl is a supported platform
            - pass:
                when: "== gke"
                message: GKE is a supported platform

but should be

        - distribution:
            outcomes:
              - pass:
                  when: "== kurl"
                  message: kurl is a supported platform
              - pass:
                  when: "== gke"
                  message: GKE is a supported platform

Proposal: Detect likely format errors To whatever extent we can, which may be "not much", try to hint that this may be a yaml/parse error when the body of an analyzer evaluates to null.

A proposed error message might look like

Could not parse an analyzer at index $N. Please ensure the object key is a valid analyzer type and parameters are indented as children of the analyzer type name. See $DOCS_LINK for more information.

Screenshot 2024-01-28 at 6 21 22 PM

Proposal: Strict format requirements it seems like the YAML parser that consumes the list element evaluates to distribution = nil and then just drops the outcomes block on the floor since it can't be unmarshalled onto any known struct field of type Analyze. Y'all could consider failing or warning whenever unrecognized fields are provided, but this has some backwards-compatibility issues and probably needs some kind of strict-parsing opt-in. For example in the actual failed analyzer UI, could show something like

Parse error at index $N (or line: $N) -- one or more unknown object fields will be ignored: [outcomes].

Describe alternatives you've considered

I suppose I could make fewer yaml mistakes 😅

Additional context

@banjoh
Copy link
Member

banjoh commented Apr 22, 2024

I believe this is related to #1312

@banjoh
Copy link
Member

banjoh commented Jun 11, 2024

Analysis will fail if the analyser given is deemed non-existent, say it has been misspelled, or the binary executing the analysis is old and does not include the implementation of the given analyser

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

No branches or pull requests

2 participants