Skip to content

Conversation

@SVilgelm
Copy link
Contributor

@SVilgelm SVilgelm commented Oct 28, 2025

Add test cases to decode_test.go and encode_test.go that cover an edge case described in issue #157 where a struct field uses an incorrect tag syntax (a bare string like bar without the yaml: prefix) alongside a correct yaml:"foo" tag. The new tests assert that the library continues to accept and round-trip values when one field uses the supported-but-nonstandard tag form.

This clarifies expected behavior and prevents regressions for legacy struct tags that some users rely on.

Remove the redundant go vet invocation from both the GitHub Actions
workflow and the GNUmakefile. The CI workflow no longer runs
"go vet ./..." and the "vet" target and its invocation in the makefile
are deleted.

Disable the Go vet tool when running test and helper commands
to avoid vet-related failures blocking test execution. Update the main
test target so its result parsing is not affected by vet output.

Fixes #157

Copilot AI review requested due to automatic review settings October 28, 2025 18:25
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds test cases to verify that the YAML library correctly handles and round-trips struct fields with non-standard tag syntax (bare strings without the yaml: prefix) alongside standard yaml: tags, addressing issue #157.

  • Adds marshal test case for structs with mixed standard and non-standard tag formats
  • Adds unmarshal test case for structs with mixed standard and non-standard tag formats

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
encode_test.go Adds test case verifying marshaling behavior with non-compliant struct tags
decode_test.go Adds test case verifying unmarshaling behavior with non-compliant struct tags

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@SVilgelm SVilgelm force-pushed the noncompliant-struct-tag-tests branch from 5fb6764 to aa9ef1e Compare October 28, 2025 18:28
@SVilgelm SVilgelm requested a review from Copilot October 28, 2025 18:28
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@SVilgelm SVilgelm force-pushed the noncompliant-struct-tag-tests branch from aa9ef1e to f8260bf Compare October 28, 2025 18:30
@SVilgelm SVilgelm requested a review from Copilot October 28, 2025 18:30
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@ccoVeille ccoVeille left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments.

Please remove the go vet jobs from GHA and the govet in Makefile entry

You might also have to update go test calls use -vet=off as flags with GHA and Makefile, the govet linters in golangci-lint is enough and supports //nolint:govet as you said.

@ccoVeille
Copy link
Contributor

Some comments.

Please remove the go vet jobs from GHA and the govet in Makefile entry

You might also have to update go test calls use -vet=off as flags with GHA and Makefile, the govet linters in golangci-lint is enough and supports //nolint:govet as you said.

About this ☝️

It reminds me your comment in the other issue 👇

The govet is automatic with go test

not really:

(…)

As you can see, I ran go test locally and it does not fail, but go vet fails.

Originally posted by @SVilgelm in #154 (comment)

I'm unsure how you got no errors as using go test uses go vet by default with Go 1.24+

https://go.dev/doc/go1.24#vet

@SVilgelm
Copy link
Contributor Author

I don't know,

25-10-28 14:25 % go test ./...                                                                                                                                              
ok      go.yaml.in/yaml/v4      2.087s
?       go.yaml.in/yaml/v4/cmd/go-yaml  [no test files]
?       go.yaml.in/yaml/v4/internal/libyaml     [no test files]
ok      go.yaml.in/yaml/v4/internal/testutil/assert     0.615s
ok      go.yaml.in/yaml/v4/yts  1.099s

25-10-28 14:25 % go version                                                                                                                                                 
go version go1.24.9 darwin/arm64

Okay, I checked the documentation for test cmd, it says:

go test runs go vet on the package
and its test source files to identify significant problems.
...
To disable the running of go vet, use the -vet=off flag. To run all
checks, use the -vet=all flag.

Seems this particular check is disabled for test cmd. The vet tool is like golangci-lint, it also runs multiple analyzers.
To prove this idea, I run go test -vet=all and it failed.

@SVilgelm SVilgelm force-pushed the noncompliant-struct-tag-tests branch from f8260bf to 51308ab Compare October 28, 2025 21:37
@SVilgelm
Copy link
Contributor Author

I got an idea, maybe instead of removing vet target from Makefile, I should change it to invoke golangci-lint?

@ccoVeille
Copy link
Contributor

You could indeed this could do the job

golangci-lint run --enable-only govet

But, I'm unsure here. At least you would only have it in makefile and not the GHA.

I would simply remove it. But it doesn't mean I'm right about it. I get your point, I'm unsure what is the best.

As make lint is also available, I'm unsure there is a need for a make vet. I mean why having a vet target that doesn't call go vet, and call something that is also available and checked by lint target

If it is removed, there might be a need to update contributions guide.

Also, please consider adding -vet=off to go test in test target

@SVilgelm
Copy link
Contributor Author

Looks like the the lint target is not merged yet: make: *** No rule to make target lint'`

@SVilgelm
Copy link
Contributor Author

Also, please consider adding -vet=off to go test in test target

sure, will add

@SVilgelm SVilgelm force-pushed the noncompliant-struct-tag-tests branch from fb63ecc to a75392c Compare October 28, 2025 23:04
@ccoVeille
Copy link
Contributor

Looks like the the lint target is not merged yet: make: *** No rule to make target lint'`

Indeed #131 is not merged yet.

@SVilgelm SVilgelm changed the title Add cases for non-compliant struct tag Add cases for non-compliant struct tag and remove go vet check from CI and Makefile Oct 28, 2025
@SVilgelm SVilgelm mentioned this pull request Oct 28, 2025
@SVilgelm SVilgelm force-pushed the noncompliant-struct-tag-tests branch from a75392c to 87bb065 Compare October 30, 2025 02:59
@SVilgelm
Copy link
Contributor Author

@ccoVeille @ingydotnet I rebased this PR and I think it is ready

@SVilgelm SVilgelm requested a review from ccoVeille October 30, 2025 03:01
@ingydotnet
Copy link
Member

@ccoVeille @ingydotnet I rebased this PR and I think it is ready

@SVilgelm thanks. I'm out of tuits for this until at least Friday...

@SVilgelm SVilgelm force-pushed the noncompliant-struct-tag-tests branch 2 times, most recently from a56f255 to dd1e8c5 Compare October 30, 2025 14:43
@SVilgelm SVilgelm force-pushed the noncompliant-struct-tag-tests branch 2 times, most recently from 2f01b53 to e25e558 Compare November 1, 2025 00:49
@SVilgelm SVilgelm force-pushed the noncompliant-struct-tag-tests branch from 0750bdf to ce640e4 Compare November 1, 2025 21:28
SVilgelm and others added 4 commits November 2, 2025 17:37
Add test cases to decode_test.go and encode_test.go that cover an
edge case described in issue yaml#157 where a struct field uses an
incorrect tag syntax (a bare string like `bar` without the `yaml:`
prefix) alongside a correct `yaml:"foo"` tag. The new tests assert
that the library continues to accept and round-trip values when one
field uses the supported-but-nonstandard tag form.

This clarifies expected behavior and prevents regressions for legacy
struct tags that some users rely on.
Remove the redundant go vet invocation from both the GitHub Actions
workflow and the GNUmakefile. The CI workflow no longer runs
"go vet ./..." and the "vet" target and its invocation in the makefile
are deleted.

This simplifies the build steps and avoids running go vet twice or as a
separate target, keeping linting/formatting tasks consolidated (e.g.
golangci-lint).
Disable the Go vet tool when running test and helper commands
to avoid vet-related failures blocking test execution. Update the main
test target so its result parsing is not affected by vet output.

This prevents vet output from being treated as test output and keeps
CI and local test runs stable when vet reports issues that should not
fail the test invocation.
Co-authored-by: ccoVeille <[email protected]>
Apply suggestion from @ccoVeille

Co-authored-by: ccoVeille <[email protected]>
@SVilgelm SVilgelm force-pushed the noncompliant-struct-tag-tests branch from ce640e4 to fa651e9 Compare November 3, 2025 01:37
Update the lint rule in the GNUmakefile to invoke the linting
target with a package pattern instead of running the default
subcommand and remove the separate fumpt installation and format
step. The lint recipe now runs "$< run ./..." which ensures
golangci-lint (or the versioned linter) processes all packages in
the repository. Removing the fumpt-specific lines avoids installing
gofumpt during the Make process and relies on the linter or other
tooling to handle formatting, simplifying and speeding up the
Makefile workflow.
@ccoVeille
Copy link
Contributor

Let's merge and continue with other PR.

It's a test we add and some addition to makefile

@ccoVeille ccoVeille mentioned this pull request Nov 3, 2025
@ingydotnet ingydotnet merged commit 4ffec96 into yaml:main Nov 3, 2025
18 checks passed
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.

go vet fails on a test case for an invalid struct tag

3 participants