Skip to content

Comments

fix: avoid faulty duplicate detection#893

Open
Mcklmo wants to merge 3 commits intodanielgtaylor:mainfrom
Mcklmo:fix-faulty-duplicate-detection
Open

fix: avoid faulty duplicate detection#893
Mcklmo wants to merge 3 commits intodanielgtaylor:mainfrom
Mcklmo:fix-faulty-duplicate-detection

Conversation

@Mcklmo
Copy link

@Mcklmo Mcklmo commented Sep 14, 2025

The bug is caused by registering operations with inline struct definitions with varying field names, combined with an empty OperationID.

I noticed this causing a runtime panic on app start. It is no actual security vulnerability, because it is not possible to trigger during app uptime - it only triggers during the initialisation phase. But it is an irritating error to me as a user, as the panic message does not really make sense to me.

I added a test for reproducability. To see the problem in action, just run the tests on your current version, without my fix to the code.

I fixed the error by allowing multiple inline struct definitions with varying field names. What would have caused a duplicate panic before now increments the would be duplicate by one. E.g., the first type will be called "Request", the second "Request1", and so on. That way the behavior is still deterministic and humanly readable in a generated spec. This change does not affect existing code bases because the condition the change has effect on was previously guarded by the runtime panic. I.e., no configuration can have existed that was able to initialise the app with this condition before. Hence, the change will be entirely backwards compatible.

bug caused by missing reflection type name for inline struct definitions, combined with an empty OperationID
Copilot AI review requested due to automatic review settings February 16, 2026 01:42

This comment was marked as outdated.

@codecov
Copy link

codecov bot commented Feb 16, 2026

Codecov Report

❌ Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.86%. Comparing base (897fab0) to head (a142116).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
huma.go 80.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #893      +/-   ##
==========================================
- Coverage   92.89%   92.86%   -0.03%     
==========================================
  Files          23       23              
  Lines        4617     4627      +10     
==========================================
+ Hits         4289     4297       +8     
- Misses        271      272       +1     
- Partials       57       58       +1     

☔ 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.

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.

2 participants