Repository navigation
[go] Stop JobListParams.Where from mutating caller named args - #1575
Merged
brandur merged 1 commit intoNov 6, 2026
Merged
Conversation
RaphaelFakhri
force-pushed
the
fix-job-list-where-named-args
branch
from
November 3, 2026 16:51
e087fed to
702f969
Compare
Contributor
|
Hey Raphael! Could you sign our CLA please? https://github.com/riverqueue/rivercla |
Contributor
Author
|
Signed: riverqueue/rivercla#44 adds me to the signees list. |
When given more than one set of named arguments, JobListParams.Where merged later sets into the first map it was passed, so the caller's map picked up extra keys. Passing nil as the first set panicked with an assignment to a nil map. Merge into a fresh map instead, the way JobDeleteManyParams.Where already does.
brandur
force-pushed
the
fix-job-list-where-named-args
branch
from
November 6, 2026 20:41
1515e50 to
fa7bd04
Compare
brandur
approved these changes
Nov 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JobListParams.Whereaccepts several sets of named arguments and merges them, with later sets overwriting earlier ones. It merged them by copying every later set into the first map the caller passed, so that map gained or changed keys:Reusing
basein anotherWherethen sendskindto a query that doesn't reference@kind, andJobListfails withexpected "..." to contain named arg symbol @kind. The stored predicate also aliased the caller's map, so later edits to it changed params that were already built. Passingnilas the first set panicked withassignment to entry in nil map.This change merges into a new map, the way
JobDeleteManyParams.Wherealready does since #1570.Changes
job_list_params.go: merge named arguments into a fresh map inJobListParams.Where.job_list_params_test.go: addTestJobListParams_Where, mirroringTestJobDeleteManyParams_Where, covering the merge result, unmodified inputs, and anilfirst set.CHANGELOG.md: add an entry underUnreleased.Testing
Without the fix, both subtests fail:
MergesNamedArgsWithoutMutatingThemreports the first map changed to{"a":1, "b":3}, andNilFirstNamedArgspanics withassignment to entry in nil map. With the fix, both pass.golangci-lint run .(v2.14.0) reports 0 issues.