fix: agent artifact route to support filenames with slashes#7490
fix: agent artifact route to support filenames with slashes#7490devcatalin wants to merge 2 commits intomainfrom
Conversation
Greptile SummaryFixes a routing bug where artifact filenames containing subdirectory paths (e.g. Confidence Score: 5/5Safe to merge — targeted one-line routing fix with a solid test covering the exact failure scenario. The change is minimal and correct: No files require special attention.
|
| Filename | Overview |
|---|---|
| internal/app/api/v1/server.go | Single-character change: :filename → :filename+; correct and minimal, no routing conflicts with adjacent routes. |
| internal/app/api/v1/testworkflowexecutions_artifact_test.go | New table-driven test covering simple filenames, one-level, and nested subdirectory paths through the real Fiber route + mock storage; verifies the greedy param fix end-to-end. |
Sequence Diagram
sequenceDiagram
participant CloudAPI as Cloud API
participant NATS
participant Agent as Agent (Fiber/fasthttp)
participant Storage as Artifact Storage
CloudAPI->>NATS: GET /artifacts/results%2Fjunit.xml
NATS->>Agent: Forward request
Note over Agent: fasthttp URI.Parse decodes<br/>%2F → / before routing
Note over Agent: Path becomes /artifacts/results/junit.xml
alt Before fix (/:filename)
Agent-->>NATS: No route match → no response
NATS-->>CloudAPI: 408 Timeout
else After fix (/:filename+)
Agent->>Agent: Greedy param captures results/junit.xml
Agent->>Storage: DownloadFile("results/junit.xml", ...)
Storage-->>Agent: File stream
Agent-->>NATS: 200 OK + file content
NATS-->>CloudAPI: 200 OK
end
Reviews (1): Last reviewed commit: "fix: agent artifact route to support fil..." | Re-trigger Greptile
There was a problem hiding this comment.
Pull request overview
This PR fixes the agent-side Fiber route for fetching test-workflow execution artifacts so that artifact filenames containing slashes (subdirectory paths like results/junit.xml) are routable after URL decoding, preventing proxy timeouts seen by the cloud API.
Changes:
- Update the artifact download route to use Fiber’s greedy path param (
:filename+) so multi-segment filenames match. - Add an end-to-end-style handler test that verifies artifacts can be fetched when the filename contains encoded slashes (
%2F) that decode to/.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/app/api/v1/server.go | Switch artifact route from single-segment :filename to greedy :filename+ to support slashed filenames. |
| internal/app/api/v1/testworkflowexecutions_artifact_test.go | Add coverage ensuring the Fiber route + handler + storage call chain works for filenames containing /. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Change c.Params("filename") to c.Params("filename+") to match
Fiber's greedy route naming convention for /:filename+ routes
- Add url.PathUnescape() to decode %2F back to / before storage lookup
- Increase reconnection test timeouts to prevent flaky failures
- Add artifact-subdirectory test workflow for manual reproduction
Companion fix to kubeshop/testkube-cloud-api#3489 - resolves the second layer of the artifact 410/408 bug.
results/junit.xml); the cloud API proxies these to the agent via NATS with%2F-encoded slashesURI.Parsedecodes%2F→/before Fiber routing, so:filename(single-segment) can't match multi-segment decoded paths — the agent silently drops the request, causing a 408 timeout at the cloud API:filename→:filename+(Fiber greedy param) so the route matches filenames with slashes, matching the cloud API fix ({filename:.*})