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.
fix: validate country field with valid Adzuna country codes (Issue #1301) #1302
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
base: main
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
fix: validate country field with valid Adzuna country codes (Issue #1301) #1302
Changes from all commits
089eb68File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: Canopus-Labs/PrepPilot
Length of output: 8341
🏁 Script executed:
Repository: Canopus-Labs/PrepPilot
Length of output: 10803
🌐 Web query:
Express 5.1 application query parser default simple repeated query parameters arrays official documentation💡 Result:
In Express 5.1, the default setting for the
query parserapplication setting is 'simple' [1][2]. This parser uses the Node.js built-inquerystringmodule rather than theqslibrary that was used as the default in previous versions [1][2]. Because of this change, the 'simple' parser does not automatically parse repeated query parameters or bracketed parameters (e.g.,items[]) into arrays [3][4]. If you require array parsing for repeated query parameters, you must change thequery parsersetting [1]. To restore behavior similar to Express 4 (whereqshandles array parsing), you can set the parser to 'extended' [4][2]: app.set('query parser', 'extended'); The 'extended' parser uses theqslibrary, which automatically parses repeated query parameters and bracketed syntax into arrays [4][5]. Note that when using the 'extended' parser, there is a defaultarrayLimitof 1000, which ensures that repeated keys are correctly returned as arrays rather than objects for up to 1000 items [6][5]. If you need further customization (such as specificqsoptions), you can also provide a custom function to thequery parsersetting [7]: const qs = require('qs'); app.set('query parser', (str) => qs.parse(str, { /* custom options */ }));Citations:
item[]format is parsed differently in express v5 compared to v4 expressjs/express#5060Reject non-string
countryvalues before lowercasing.With Express 5.1’s default parser,
?country=us&country=caproduces an array..toLowerCase()then throws, andgetJobsreturns HTTP 500 instead of HTTP 400. Add atypeof country === "string"guard and a regression test.🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Validate
countrybefore configuration and database work.The validation block runs after the disabled-configuration response and after
Session.findOne(). An unsupported country therefore receives HTTP 200 when Adzuna is disabled, and it can receive HTTP 500 if the session lookup fails. This conflicts with the stated contract that invalid codes return HTTP 400.Move country extraction and validation before both operations.
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Use the normalized default country in
refreshJobCache.If
ADZUNA_COUNTRY=US,getJobsuses arole|uscache key, butrefreshJobCacheat Lines 123-124 usesrole|US. The scheduled refresh then writes a cache entry thatgetJobsdoes not read. Normalize the default once and pass that value to both the cache key andfetchFromAdzuna().🤖 Prompt for AI Agents
Uh oh!
There was an error while loading. Please reload this page.