Fix 500s on network location PATCH without base_url and on malformed basic-auth facility ids
๐ Looking for an issue? Welcome! This issue is open for contribution. If this is the first time youโre requesting an issue, please:
- Read Contributing guidelines carefully. Pay extra attention to Using generative AI. Pull requests and comments that donโt follow the guidelines wonโt be answered.
- Confirm that youโve read the guidelines in your comment.
Overview
Two auth and discovery paths return a 500 for malformed input: a network location PATCH without base_url, and basic authentication against the public facility user endpoint with a malformed facility id. The first should succeed and the second should fail authentication.
Complexity: Low Target branch: develop
Context
On develop at fe298f5449:
PATCH /api/discovery/staticnetworklocation/<id>/with{"nickname": "x"}raisesKeyError: 'base_url'in the serializer'svalidate(network_location.py#L71). (device permission or facility admin)GET /api/public/facilityuser/with basic authusername=learner&facility=bad:passwordraisesValueErrorinbackends.py#L117, which catches onlyDoesNotExist. (anonymous)
The Change
- The network location serializer should validate
base_urlonly when the request includes it. - The basic-auth backend should treat a malformed facility id as a failed authentication.
Acceptance Criteria
- [ ] The
PATCHunder Context returns 200 and changes onlynickname. - [ ] The basic-auth request under Context returns 401.
- [ ] Tests cover both requests.
AI usage
I had Claude Code sweep Kolibri's API code for unvalidated request input and reproduce each 500 with a test. I chose the fix and the split into sub-issues. Claude Code drafted the issue to the pattern of #15838.
Hi! ๐
This issue is available for contribution and supports self-assignment. Here's how to get started:
- Comment
/assignto assign yourself to this issue - You can have up to 2 issues assigned at a time across all community repos
- Dropping an issue has a 7-day cooldown before the slot opens up
- Link your pull request to this issue when you submit it
๐ Read the Contributing guidelines before starting.
Are you preparing for Google Summer of Code? See our GSoC guidelines.
Hi! ๐
This issue is available for contribution and supports self-assignment. Here's how to get started:
- Comment
/assignto assign yourself to this issue - You can have up to 2 issues assigned at a time across all community repos
- Dropping an issue has a 7-day cooldown before the slot opens up
- Link your pull request to this issue when you submit it
๐ Read the Contributing guidelines before starting.
Are you preparing for Google Summer of Code? See our GSoC guidelines.
/assign
Hi! ๐
You've been assigned to this issue. Here's what to do next:
- Read the issue description carefully and make sure you understand the requirements
- Link your pull request to this issue when you submit it
- If you can no longer work on this, unassign yourself so others can pick it up
Good luck! ๐
Are you preparing for Google Summer of Code? See our GSoC guidelines.
I've read the contributing guidelines, including the section on generative AI.
The network location serializer runs address discovery on every validate, so a PATCH without base_url hits a KeyError; it now skips discovery when the request has no base_url. The basic-auth facility lookup only catches DoesNotExist, so a malformed id raises the ValueError from the UUID field; it now catches that too and fails authentication with a 401, the same way csv_utils.infer_facility handles it. Each path gets one API test that fails on develop.