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

0.13: [Bug]: Spec validation error message is printed with JSON encoding #5446

Closed
stefreak opened this issue Nov 20, 2023 · 0 comments · Fixed by #5745
Closed

0.13: [Bug]: Spec validation error message is printed with JSON encoding #5446

stefreak opened this issue Nov 20, 2023 · 0 comments · Fixed by #5745

Comments

@stefreak
Copy link
Member

stefreak commented Nov 20, 2023

Garden Bonsai (0.13) Bug

Current Behavior

When the spec.command field is not defined in an exec Test action, I currently get the following error message:

Error validating spec for Test type=exec name=foo:
[
  {
    "code": "invalid_type",
    "expected": "array",
    "received": "undefined",
    "path": [
      "command"
    ],
    "message": "Required"
  }
]

Expected behavior

I expect a human-readable error message, something like this:

Error validating spec for Test type=exec name=foo:

...
25  | type: exec
26  | name: foo
------------^
Expected an array at 'spec.command', actually received 'undefined'.

Reproducible example

Command: garden test

# garden.yml

apiVersion: garden.io/v1
kind: Project
name: foo
environments:
  - name: local

---

kind: Test
type: exec
name: foo

Workaround

Suggested solution(s)

Additional context

Your environment

  • OS: macOS

garden version 0.13.20

@stefreak stefreak added the 0.13 label Nov 20, 2023
@vvagaytsev vvagaytsev added the bug label Jan 18, 2024
github-merge-queue bot pushed a commit that referenced this issue Feb 19, 2024
<!--  Thanks for sending a pull request! Here are some tips for you:

1. If this is your first pull request, please read our contributor
guidelines in the
https://github.com/garden-io/garden/blob/main/CONTRIBUTING.md file.
2. Please label this pull request according to what type of issue you
are addressing (see "What type of PR is this?" below)
3. Ensure you have added or run the appropriate tests for your PR.
4. If the PR is unfinished, add `WIP:` at the beginning of the title or
use the GitHub Draft PR feature.
5. Please add at least two reviewers to the PR. Currently active
maintainers are: @edvald, @thsig, @eysi09, @shumailxyz, @stefreak,
@TimBeyer, @mkhq, and @vvagaytsev.
-->

**What this PR does / why we need it**:

Before this fix, we were simply passing through the default error
messages generated by Zod when validation failed. This resulted in
JSON-like error messages when a Zod schema validation error happened.

This was fixed by detecting Joi VS Zod validation errors, and adding a
little rendering logic for Zod errors to improve the output.

**Which issue(s) this PR fixes**:

Fixes #5446.

**Special notes for your reviewer**:

Before this fix, introducing an `exec` Test with a missing
`spec.command` would result in an error message like this:

![Screenshot 2024-02-19 at 12 06
18](https://github.com/garden-io/garden/assets/382137/ad038cdd-b624-42fe-a7e8-a66951bb5c9b)

After this fix:

![Screenshot 2024-02-19 at 12 05
33](https://github.com/garden-io/garden/assets/382137/41a5527b-70c9-4e4a-bb4f-04930bc5087b)

---------

Co-authored-by: Vladimir Vagaytsev <vladimir.vagaitsev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants