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
feat(config): better error messages around schema validation #4889
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some test failures, please take a look.
Does this work as expected with YAML files that contain multiple docs? const lineCounter = new LineCounter()
const parser = new Parser(lineCounter.addNewLine)
const tokens = parser.parse(content)
const docsGenerator = new Composer().compose(tokens)
const docs = Array.from(docsGenerator) as Document.Parsed<ParsedNode>[] to get the docs and then use |
I hadn't tested that specifically, good catch. Not sure I fully follow your code there though. Happy to take commits on this PR btw, it's very much a draft still, bunch of broken tests etc. |
Btw, in case it simplifies the implementation I think it's acceptable if we just show the YAML doc/subdoc that the error came from, even it it's a sub-doc of a larger one—we just need to help the user quickly pinpoint the source location. |
271923d
to
23d0f28
Compare
23d0f28
to
b52f68c
Compare
yamlDocBasePath = ["providers", i] | ||
return false | ||
} | ||
return true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this statement always break the loop after the first iteration? Was it done intentionally? It looks like the returned boolean
value is never used, do we need it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's intentional. The boolean needs to be there, linter complains if we only return it to break.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, got it, thanks! It may make sense to leave a short comment on that :)
I left a few comments and questions, please check. |
This attaches the YAML parse results to configs when loading, and leverages that when rendering validation error messages. This should be a useful step for an IDE highlighting integration as well.
6182df8
to
2cb20c5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👍 Thanks for the great improvement! 💯
@edvald would you have time to resolve the conflicts soon? I can also take a look, please let me know if you need to hand this over. It would be nice to include it in one of the upcoming releases. |
Just did that actually, good timing :) Just grappling with my merge commit now. |
Ok, should be ready now, pending tests passing. |
Now there are more conflicts to be resolved. |
Updated again. |
path: ObjectPath | undefined | ||
value: any | ||
resolved: any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opted to keep this even though the typed detail object was removed, since we are likely to use this (and potentially more) later for e.g. a language server implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! 💯
This attaches the YAML parse results to configs when loading, and leverages that when rendering validation error messages.
This should be a useful step for an IDE highlighting integration as well.