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

Better error messages for schema validation #16097

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PollRobots
Copy link
Contributor

@PollRobots PollRobots commented May 1, 2024

This PR improves the error messages produced during project schema validation so that, where possible, we suggest valid attribute names that the user may have meant to type. For instance, if they provide a "Name" attribute where we wanted "name" (lowercase "n"), we'll now say so. Where there is not a close match, we'll enumerate the full list of
valid names to try and guide the user.

Matching is implemented using Levenshtein distances and ignores case. Some examples of the new functionality:

  • {"Name": ...} yields project is missing a 'name' attribute; found 'Name' instead
  • {..., "rutnime": ...} yields project is missing a 'runtime' attribute; found 'rutnime' instead
  • {..., "template": {"displayNameDisplayName": ...}, ...} yields 'displayNameDisplayName' not allowed; the allowed attributes are 'config', 'description', 'displayName', 'important', 'metadata' and 'quickstart'

@PollRobots PollRobots requested a review from a team as a code owner May 1, 2024 00:25
@pulumi-bot
Copy link
Contributor

pulumi-bot commented May 1, 2024

Changelog

[uncommitted] (2024-06-12)

Features

  • [sdk/go] Suggest valid attributes with similar names to unrecognised ones when validating project definitions.
    #16097

@PollRobots PollRobots requested a review from Zaid-Ajaj May 1, 2024 19:57
This commit improves the error messages produced during project schema
validation so that, where possible, we suggest valid attribute names
that the user may have meant to type. For instance, if they provide a
"Name" attribute where we wanted "name" (lowercase "n"), we'll now say
so. Where there is not a close match, we'll enumerate the full list of
valid names to try and guide the user.

Matching is implemented using Levenshtein distances and ignores case.
Some examples of the new functionality:

* `{"Name": ...}` yields `project is missing a 'name' attribute; found
  'Name' instead`
* `{..., "rutnime": ...}` yields `project is missing a 'runtime'
  attribute; found 'rutnime' instead`
* `{..., "template": {"displayNameDisplayName": ...}, ...}` yields
  `'displayNameDisplayName' not allowed; the allowed attributes are
  'config', 'description', 'displayName', 'important', 'metadata' and
  'quickstart'`
@lunaris lunaris force-pushed the proberts/better-project-load-errors branch from feb9ada to dc7a4eb Compare June 12, 2024 17:29
@lunaris lunaris removed the request for review from Zaid-Ajaj June 12, 2024 17:30
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

Successfully merging this pull request may close these issues.

None yet

3 participants