Skip to content

fix: preserve nested JSON tag paths in error keys#309

Merged
inhere merged 1 commit intogookit:masterfrom
almas-x:almas-297
Sep 3, 2025
Merged

fix: preserve nested JSON tag paths in error keys#309
inhere merged 1 commit intogookit:masterfrom
almas-x:almas-297

Conversation

@almas-x
Copy link
Contributor

@almas-x almas-x commented Sep 2, 2025

close #297
close #282

  • Error keys now correctly use full JSON tag paths in nested arrays and structs.
  • Resolves issue where error keys were missing JSON tags, e.g., "extras.0.github" instead of "github".

@coveralls
Copy link

Pull Request Test Coverage Report for Build 17399837106

Details

  • 4 of 6 (66.67%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.06%) to 96.687%

Changes Missing Coverage Covered Lines Changed/Added Lines %
data_source.go 4 6 66.67%
Totals Coverage Status
Change from base Build 17230117630: -0.06%
Covered Lines: 2948
Relevant Lines: 3049

💛 - Coveralls

@inhere inhere requested a review from Copilot September 2, 2025 10:04
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 fixes an issue where error keys for nested JSON structures were not preserving the full JSON tag paths, instead returning incomplete field names. The fix ensures that when validating nested arrays and structs with JSON tags, the error keys correctly reflect the complete JSON path.

Key changes:

  • Enhanced error key generation to preserve JSON tag paths in nested structures
  • Added comprehensive test coverage for both regular struct fields and JSON-tagged fields
  • Updated existing test assertions to reflect the corrected error key format

Reviewed Changes

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

File Description
issues_test.go Added test cases for issue #297 and updated existing test assertions to match corrected error key format
data_source.go Enhanced array/slice processing to maintain JSON tag paths in error keys for nested structures

@inhere inhere merged commit 74906af into gookit:master Sep 3, 2025
11 of 18 checks passed
@almas-x almas-x deleted the almas-297 branch September 3, 2025 02:00
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.

Nested JSON tag paths are not respected Slice validation errors miss data on marshal

4 participants