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

fix(binding): prevent duplicate decoding and add validation in decodeToml #4193

Merged
merged 1 commit into from
Mar 20, 2025

Conversation

revevide
Copy link
Contributor

// binding/toml.go:29
func decodeToml(r io.Reader, obj any) error {
	decoder := toml.NewDecoder(r)
	if err := decoder.Decode(obj); err != nil {
		return err
	}
	return decoder.Decode(obj)
}
  • Removed the redundant second call to decoder.Decode(obj) which caused incorrect behavior.
  • Added a validate(obj) function to ensure proper validation of decoded TOML data.
  • Fixes potential issues with data integrity caused by duplicate decoding.

@appleboy appleboy added the bug label Mar 20, 2025
@appleboy appleboy added this to the v1.11 milestone Mar 20, 2025
Copy link

codecov bot commented Mar 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.99%. Comparing base (3dc1cd6) to head (0a36ef7).
Report is 95 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4193      +/-   ##
==========================================
- Coverage   99.21%   98.99%   -0.22%     
==========================================
  Files          42       44       +2     
  Lines        3182     3395     +213     
==========================================
+ Hits         3157     3361     +204     
- Misses         17       24       +7     
- Partials        8       10       +2     
Flag Coverage Δ
?
--ldflags="-checklinkname=0" -tags "sonic avx" 98.99% <100.00%> (?)
-tags go_json 98.99% <100.00%> (?)
-tags nomsgpack 98.98% <100.00%> (?)
go-1.18 ?
go-1.19 ?
go-1.20 ?
go-1.21 ?
go-1.23 98.99% <100.00%> (?)
go-1.24 98.99% <100.00%> (?)
macos-latest 98.99% <100.00%> (-0.22%) ⬇️
ubuntu-latest 98.99% <100.00%> (-0.22%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@appleboy appleboy merged commit e737e3e into gin-gonic:master Mar 20, 2025
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants