Repository navigation
Don't error for bad locale strings - #1117
Merged
Merged
Conversation
Test coverage94.19% line coverage reported by SimpleCov. |
raspberrypiherokubot
temporarily deployed
to
editor-api-p-dont-error-ixyfbt
November 17, 2026 10:50
Inactive
https://raspberrypifoundation.sentry.io/issues/7848588785/events/latest/?environment=production&project=6143981&query=is%3Aunresolved&referrer=latest-event Previously a mailformed request such as `/api/projects/blank-python-starter?locale=en-US%00%2f%2e%2e%2f...` reached Postgres with a null byte in the bind parameter, so PG raised a "string contains null byte" error. This change makes ProjectLoader ignore any requested locale that is not between two and eight letters or hyphens, before falling back to `'en'`. I've decided on quite a loose regex for locales as the locales we support for projects are different to the ones supported in this app in locales.rb and I didn't want to possibly valid future locales. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
zetter-rpf
force-pushed
the
dont-error-on-bad-locales
branch
from
November 17, 2026 10:51
f0dfd52 to
b609ed5
Compare
zetter-rpf
marked this pull request as ready for review
November 17, 2026 10:51
ApprovabilityVerdict: Would Approve Macroscope's review found this PR approvable — Malformed locale preferences are now ignored while preserving existing project-selection fallbacks. The change is limited to lookup input filtering, with regression coverage for malformed input and preference ordering. Needs human approval because:
You can add or adjust custom eligibility rules. Learn more. |
cocomarine
approved these changes
Nov 17, 2026
This branch was previously deployed
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.
Fixes https://raspberrypifoundation.sentry.io/issues/7848588785/events/latest/?environment=production&project=6143981&query=is%3Aunresolved&referrer=latest-event
Previously a mailformed request such as
/api/projects/blank-python-starter?locale=en-US%00%2f%2e%2e%2f...reached Postgres with a null byte in the bind parameter, so PG raised a "string contains null byte" error.This change makes ProjectLoader ignore any requested locale that is not between two and eight letters or hyphens, before falling back to
'en'.I've decided on quite a loose regex for locales as the locales we support for projects are different to the ones supported in this app in locales.rb and I didn't want to possibly valid future locales.