Handle invalid JSON from release API safely (HEIMDALL-D2) #287

Merged
arnaud.dartois merged 1 commits from fix/7449-release-api-invalid-json into main 2026-11-07 19:22:21 +01:00
Owner

Summary

  • Bound Forgejo release response reads to 1 MiB and return the existing unavailable result for HTML or malformed JSON.
  • Preserve cancellation and avoid logging provider response contents.
  • Add focused tests and the release-api-responses workflow skill.

Closes #280

Validation evidence

  • dotnet test tests/Heimdall.Web.Tests/Heimdall.Web.Tests.csproj --no-restore --filter FullyQualifiedName~UpdatesControllerRetryTests — passed, 11/11.
  • dotnet build src/Heimdall.Web/Heimdall.Web.csproj --no-restore --configuration Release — passed, 0 warnings and 0 errors.
  • git diff --check — passed.
  • Disposable Compose used source commit cf017b49da2b07ffc9e902a7007fbbc1f2a8361b, project heimdall-7449-both-1794072540-2109, and unique Central tag heimdall:heimdall-7449-both-1794072540-2109-central. Its HTTPS nginx mock used an ephemeral CA and SAN-matched certificate; the read-only CA mount was trusted only by Central via SSL_CERT_FILE, with TLS validation enabled.
  • The mock returned 200 application/json for a minimal valid Forgejo release and 200 text/html for the malformed provider response. Through the authenticated settings API, the real GET /api/updates/latest returned HTTP 200 with version v-acceptance-7.8.9 for valid JSON, and the established HTTP 502 JSON response for HTML instead of a 500/JsonException.
  • Cleanup verified project containers, volumes, and networks absent and the exact Central image tag absent; generated credentials, certificates, Compose files, and temporary publish output were removed. Shared upstream images were retained.
  • Required CI is pending. No production-provider validation is claimed.
## Summary - Bound Forgejo release response reads to 1 MiB and return the existing unavailable result for HTML or malformed JSON. - Preserve cancellation and avoid logging provider response contents. - Add focused tests and the `release-api-responses` workflow skill. Closes #280 ## Validation evidence - `dotnet test tests/Heimdall.Web.Tests/Heimdall.Web.Tests.csproj --no-restore --filter FullyQualifiedName~UpdatesControllerRetryTests` — passed, 11/11. - `dotnet build src/Heimdall.Web/Heimdall.Web.csproj --no-restore --configuration Release` — passed, 0 warnings and 0 errors. - `git diff --check` — passed. - Disposable Compose used source commit `cf017b49da2b07ffc9e902a7007fbbc1f2a8361b`, project `heimdall-7449-both-1794072540-2109`, and unique Central tag `heimdall:heimdall-7449-both-1794072540-2109-central`. Its HTTPS nginx mock used an ephemeral CA and SAN-matched certificate; the read-only CA mount was trusted only by Central via `SSL_CERT_FILE`, with TLS validation enabled. - The mock returned `200 application/json` for a minimal valid Forgejo release and `200 text/html` for the malformed provider response. Through the authenticated settings API, the real `GET /api/updates/latest` returned HTTP 200 with version `v-acceptance-7.8.9` for valid JSON, and the established HTTP 502 JSON response for HTML instead of a 500/`JsonException`. - Cleanup verified project containers, volumes, and networks absent and the exact Central image tag absent; generated credentials, certificates, Compose files, and temporary publish output were removed. Shared upstream images were retained. - Required CI is pending. No production-provider validation is claimed.
arnaud.dartois added 1 commit 2026-11-07 18:20:08 +01:00
fix: handle invalid release API JSON (#280)
Heimdall Gitea / Detect CI scope (pull_request) Successful in 6s
Heimdall Gitea / Build and tests (pull_request) Successful in 17m51s
Heimdall Gitea / Publish versioned release (pull_request) Skipped
Heimdall Gitea / Build and scan server image (pull_request) Successful in 8m25s
Heimdall Gitea / Build and scan agent image (pull_request) Successful in 11m28s
Heimdall Gitea / Publish Docker Hub latest tags (pull_request) Skipped
Heimdall Gitea / Build and scan NVIDIA Agent image (pull_request) Successful in 19m34s
Heimdall Gitea / CI policy (pull_request) Successful in 4s
cf017b49da
Author
Owner

Targeted disposable HTTPS mock acceptance (2026-11-07):

  • Compose project: heimdall-7449-tls-1794072337-1950; local Central image tag: heimdall:heimdall-7449-tls-1794072337-1950-central. The only helper image was shared upstream nginx:1.27-alpine and was retained.
  • Generated an ephemeral CA and a server certificate with DNS:release-mock SAN. The nginx mock returned HTTPS HTTP 200 with text/html; Central trusted only the mounted read-only CA bundle through SSL_CERT_FILE. No certificate validation was disabled.
  • Verified the mock response from Central's Compose network: 200 text/html.
  • Configured updates.releaseapiurl=https://release-mock/latest in this disposable database and called the real GET /api/updates/latest; Central returned HTTP 502 with the established Failed to fetch release info JSON response rather than HTTP 500/JsonException.
  • Cleanup evidence: Compose down completed; containers=none, volumes=none, networks=none for the project; exact image tag heimdall:heimdall-7449-tls-1794072337-1950-central was absent after removal. Temporary environment, certificates, configuration, and copied publish files were removed.

This targeted criterion is now verified alongside the 11/11 focused tests and Release build recorded above. Issue remains open pending PR checks and merge; no production or field validation is claimed.

Targeted disposable HTTPS mock acceptance (2026-11-07): - Compose project: `heimdall-7449-tls-1794072337-1950`; local Central image tag: `heimdall:heimdall-7449-tls-1794072337-1950-central`. The only helper image was shared upstream `nginx:1.27-alpine` and was retained. - Generated an ephemeral CA and a server certificate with `DNS:release-mock` SAN. The nginx mock returned HTTPS HTTP 200 with `text/html`; Central trusted only the mounted read-only CA bundle through `SSL_CERT_FILE`. No certificate validation was disabled. - Verified the mock response from Central's Compose network: `200 text/html`. - Configured `updates.releaseapiurl=https://release-mock/latest` in this disposable database and called the real `GET /api/updates/latest`; Central returned HTTP 502 with the established `Failed to fetch release info` JSON response rather than HTTP 500/JsonException. - Cleanup evidence: Compose down completed; containers=none, volumes=none, networks=none for the project; exact image tag `heimdall:heimdall-7449-tls-1794072337-1950-central` was absent after removal. Temporary environment, certificates, configuration, and copied publish files were removed. This targeted criterion is now verified alongside the 11/11 focused tests and Release build recorded above. Issue remains open pending PR checks and merge; no production or field validation is claimed.
Author
Owner

Both required real endpoint paths verified in the same disposable Compose run (2026-11-07):

  • Source: existing PR source commit cf017b49da2b07ffc9e902a7007fbbc1f2a8361b; no production source changes were made for this probe.
  • Project heimdall-7449-both-1794072540-2109 used a unique Central image heimdall:heimdall-7449-both-1794072540-2109-central, generated database/JWT credentials, distinct loopback ports, isolated named network and volumes. The shared upstream helper image nginx:1.27-alpine was retained.
  • A generated ephemeral CA signed a server certificate with DNS:release-mock SAN. Only Central received the CA through a read-only mount and SSL_CERT_FILE; certificate verification remained enabled.
  • From Central's Compose network, mock /valid returned 200 application/json with the minimal Forgejo release, and /invalid returned 200 text/html.
  • Used authenticated app API bootstrap and PUT /api/settings/updates.releaseapiurl to configure each route (no direct DB setting writes). Real GET /api/updates/latest returned HTTP 200 with version v-acceptance-7.8.9 for valid JSON, then HTTP 502 with Failed to fetch release info for HTML.
  • Cleanup verified project containers=none, volumes=none, networks=none, and exact Central tag heimdall:heimdall-7449-both-1794072540-2109-central absent. Temporary credentials, certificates, Compose files, and copied publish output were removed. Shared base/helper images were retained.

The Compose criterion for valid JSON and HTTP 200 HTML is now verified. PR checks remain pending at this update (CI policy waiting; build/tests in progress; detect-scope successful), so this issue remains open; no PR merge or GlitchTip resolution is claimed.

Both required real endpoint paths verified in the same disposable Compose run (2026-11-07): - Source: existing PR source commit `cf017b49da2b07ffc9e902a7007fbbc1f2a8361b`; no production source changes were made for this probe. - Project `heimdall-7449-both-1794072540-2109` used a unique Central image `heimdall:heimdall-7449-both-1794072540-2109-central`, generated database/JWT credentials, distinct loopback ports, isolated named network and volumes. The shared upstream helper image `nginx:1.27-alpine` was retained. - A generated ephemeral CA signed a server certificate with `DNS:release-mock` SAN. Only Central received the CA through a read-only mount and `SSL_CERT_FILE`; certificate verification remained enabled. - From Central's Compose network, mock `/valid` returned `200 application/json` with the minimal Forgejo release, and `/invalid` returned `200 text/html`. - Used authenticated app API bootstrap and `PUT /api/settings/updates.releaseapiurl` to configure each route (no direct DB setting writes). Real `GET /api/updates/latest` returned HTTP 200 with version `v-acceptance-7.8.9` for valid JSON, then HTTP 502 with `Failed to fetch release info` for HTML. - Cleanup verified project containers=none, volumes=none, networks=none, and exact Central tag `heimdall:heimdall-7449-both-1794072540-2109-central` absent. Temporary credentials, certificates, Compose files, and copied publish output were removed. Shared base/helper images were retained. The Compose criterion for valid JSON and HTTP 200 HTML is now verified. PR checks remain pending at this update (CI policy waiting; build/tests in progress; detect-scope successful), so this issue remains open; no PR merge or GlitchTip resolution is claimed.
arnaud.dartois merged commit 5bcd4968a8 into main 2026-11-07 19:22:21 +01:00
arnaud.dartois deleted branch fix/7449-release-api-invalid-json 2026-11-07 19:22:26 +01:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: arnaud.dartois/Heimdall#287