Skip to content

fix: apply default query params when a paginated List receives a nil request - #843

Merged
developerkunal merged 1 commit into
mainfrom
fix/list-default-query-params-nil-request
Aug 5, 2026
Merged

fix: apply default query params when a paginated List receives a nil request#843
developerkunal merged 1 commit into
mainfrom
fix/list-default-query-params-nil-request

Conversation

@developerkunal

@developerkunal developerkunal commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🔧 Changes

Addresses #826, where calling a paginated List method with a nil request pointer failed to decode with:

json: cannot unmarshal array into Go value of type management.unmarshaler

When the request is nil, internal.QueryValuesWithDefaults returned early before applying its defaults, so include_totals was never sent. The Auth0 API defaults include_totals to false and returns a bare JSON array instead of the totals-wrapped object, and the generated paginated response type can only decode the object shape, so unmarshaling failed. This affected every paginated List that relies on default query parameters (the 27 endpoints that default include_totals: true, plus page/per_page defaults on the others).

Now a nil request applies the client's default query parameters (notably include_totals=true), so the object-shaped response is returned and decodes successfully, matching the behavior of passing an empty request struct.

This mirrors the upstream Fern applyQueryDefaultsOnNilRequest generator option (fern-api/fern#17256):

  • management/internal/query.go: adds the applyQueryDefaultsOnNilRequest flag and applies defaults on a nil request when it is enabled.
  • management/internal/query_defaults_on_nil.go: enables the flag via an init function. Newer generator versions emit this file automatically; it is added manually here because this SDK is built with an older generator.
  • management/internal/query_test.go: adds coverage for the nil-request behavior with the flag enabled and disabled.
  • .fernignore: preserves the above files across regeneration.

📚 References

🔬 Testing

Covered by the added cases in management/internal/query_test.go. go build ./..., go vet ./management/..., and go test ./management/internal/... all pass.

📝 Checklist

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

@developerkunal
developerkunal enabled auto-merge (squash) August 5, 2026 05:42
@developerkunal
developerkunal merged commit 3f3810b into main Aug 5, 2026
6 checks passed
@developerkunal
developerkunal deleted the fix/list-default-query-params-nil-request branch August 5, 2026 05:45
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.05%. Comparing base (dbaffdf) to head (97f6719).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #843   +/-   ##
=======================================
  Coverage   87.05%   87.05%           
=======================================
  Files         398      399    +1     
  Lines      184157   184162    +5     
=======================================
+ Hits       160310   160315    +5     
  Misses      17863    17863           
  Partials     5984     5984           

☔ View full report in Codecov by Harness.
📢 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.

@developerkunal developerkunal mentioned this pull request Aug 5, 2026
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.

Paginated List with a nil request fails to decode: "cannot unmarshal array into Go value of type management.unmarshaler"

3 participants