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 decoding 'flag' URL query params via .decode(StructType.self) #3164

Merged
merged 4 commits into from
Jun 10, 2024

Conversation

challfry
Copy link
Contributor

@challfry challfry commented Apr 1, 2024

These changes are now available in 4.101.3

Fixes #3163.

The code:

struct QueryStruct: Content {
    var flag1: Bool?
}
let queryStruct = try req.query.decode(QueryStruct.self)

produces queryStruct.flag1 == true when decoding the URL query "?flag1", matching the behavior of req.query[Bool.self, at: "flag1"].

Copy link
Member

@0xTim 0xTim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@gwynne any thoughts?

@0xTim 0xTim added the semver-patch Internal changes only label Jun 9, 2024
@0xTim
Copy link
Member

0xTim commented Jun 9, 2024

@challfry could you fix the conflicts?

Copy link
Member

@gwynne gwynne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with it, once the conflicts are fixed

Copy link

codecov bot commented Jun 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.63%. Comparing base (11cdb29) to head (d124dcd).
Report is 28 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3164      +/-   ##
==========================================
+ Coverage   76.86%   77.63%   +0.76%     
==========================================
  Files         211      210       -1     
  Lines        8119     8137      +18     
==========================================
+ Hits         6241     6317      +76     
+ Misses       1878     1820      -58     
Files Coverage Δ
...s/Vapor/URLEncodedForm/URLEncodedFormDecoder.swift 85.25% <100.00%> (-0.56%) ⬇️

... and 95 files with indirect coverage changes

@challfry
Copy link
Contributor Author

Merge conflicts fixed.

For the failing vapor/jwt test, it appears jwt-kit changed part of their API last week, and jwt's JWTTests.swift is yet to be updated.

@0xTim 0xTim merged commit f1c3495 into vapor:main Jun 10, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-patch Internal changes only
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'Flag' URL Query params don't decode into structs
3 participants