Repository navigation
fix: reject service URLs with spaces - #357
Conversation
Service URLs with leading or trailing spaces were stored as written, as only the checks stripped them. With FOCA 0.21's response validation, one such value would fail whole lists. Reject them with 400, like links. Closes #356 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Also rewrap a paragraph of the API docs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideService URL validation no longer strips leading or trailing spaces: the existing URL validators now reject them, preventing invalid values from being stored during registration or verification. Documentation and release guidance describe the behavior change, with regression tests covering POST/PUT registration and PUT verification. Sequence diagram for rejecting whitespace in service URLssequenceDiagram
actor Client
participant API
participant Validator
participant Registry
Client->>API: POST or PUT /services
API->>Validator: normalize_url(url)
Validator-->>API: InvalidService for surrounding whitespace
API-->>Client: 400 Bad Request
Note over API,Registry: Invalid URL is not stored
Client->>API: PUT verification
API->>Validator: check_url_scheme(url, schemes)
Validator-->>API: InvalidService for surrounding whitespace
API-->>Client: 400 Bad Request
Flow diagram for service URL validation behaviorflowchart LR
Input[Service URL] --> Normalize["normalize_url(url)"]
Input --> Scheme["check_url_scheme(url, schemes)"]
Normalize --> Reject[400 Bad Request]
Scheme --> Reject
Reject --> NotStored[URL is not stored]
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #357 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 23 23
Lines 2579 2579
=========================================
Hits 2579 2579 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Linked issues
#356 Service URLs with surrounding spaces are stored · 2 of 3 met · 1 to check by hand
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | POST and PUT /services and PUT verifications with leading or trailing spaces return 400 | ✅ Met | The service URL checks no longer strip spaces; registration rejects the URL with InvalidService (a BadRequest), and verification rejects it through service_key(). Tests cover both registration modes and verification. |
| 2 | Remove the tolerance from code and docs, and mention the change in the rc2 release notes | ✅ Met | The strip calls are removed, the API docs describe rejecting whitespace around URLs, and the rc2 release notes mention the change. |
| 3 | Coverage stays at 100% | 👀 Check by hand (runtime) | Run the coverage report on the final branch to confirm it remains at 100%; the description says the reported measurement was taken before later test corrections. |
Sourcery assessment
Approved.
Summary
A service
urlwith leading or trailing spaces now returns400 Bad RequestonPOSTandPUT /servicesand onPUTverifications, instead of being stored as written. Rejecting matches how the registry handles links, and what theExternalServiceRegisterschema already says. The strip branches innormalize_url()andcheck_url_scheme()are gone. The API docs, the upgrade steps and the rc2 release notes are updated.Closes #356
Verification
Run locally on the branch:
pytestwithout the chart tests: 1752 passed, 11 skipped (tests/test_chart.pyandTestChartOverlayexcluded)coverage report: 100%, measured on the first commit, in a run where the chart tests failed and 2 outdated test cases were later correctedruff check,ruff format --check,mypy: passmkdocs build --strict: passesNot run locally:
helm dependency build deploymentfailed here with a mise error, so they failed for lack of the library chart; left to CIsemgrep: it could not write its settings in the sandbox; left to the push hook and CIDeclined review findings
service_key()has no startup caller, and rc2 needs a fresh database, so no such data exists. For the same reason,warn_url_schemesblaming the scheme of such a stored URL needs no change.Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Reject service URLs containing surrounding whitespace and document the resulting API behavior.
Bug Fixes:
Enhancements:
Documentation:
Tests: