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: Honor struct tags on WriteData and avoid panic for unexported fields #113

Merged
merged 5 commits into from
Nov 6, 2024

Conversation

srebhan
Copy link
Contributor

@srebhan srebhan commented Oct 31, 2024

Proposed Changes

In the current implementation, the WriteData function will check the tagged structure before processing it. This has the drawback that the function will error out for invalid fields even though those fields are not meant to be exported by either being tagged lp:"-" or by not being tagged at all.

Furthermore, the current code panics for unexported fields because Interface() will panic on those fields (see documentation).

This PR moves the structure checks to a point where we can be sure that the field needs to be exported. Furthermore, the PR handles tagged unexported fields without panic.

Checklist

  • CHANGELOG.md updated
  • Rebased/mergeable
  • A test has been added if appropriate
  • Tests pass
  • Commit messages are conventional
  • Sign CLA (if not already signed)

Copy link

codecov bot commented Oct 31, 2024

Codecov Report

Attention: Patch coverage is 69.23077% with 16 lines in your changes missing coverage. Please review.

Project coverage is 81.02%. Comparing base (5666748) to head (db9ecb2).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
influxdb3/write.go 69.23% 14 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #113      +/-   ##
==========================================
- Coverage   86.12%   81.02%   -5.10%     
==========================================
  Files          15       14       -1     
  Lines        1211     1186      -25     
==========================================
- Hits         1043      961      -82     
- Misses        139      195      +56     
- Partials       29       30       +1     

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

@vlastahajek
Copy link
Contributor

@srebhan, thank you for the PR and the fix. Great job! 👍
Are you going to fix the reported check failures?

@bednar
Copy link
Member

bednar commented Nov 6, 2024

@vlastahajek, the linter is fixed and CHANGELOG.md has been updated. Please take a look for the final review.

@bednar bednar added this to the 0.14.0 milestone Nov 6, 2024
@bednar bednar merged commit 349a67f into InfluxCommunity:main Nov 6, 2024
7 of 9 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.

3 participants