Skip to content

Web UI: fix download failing with authentication error - #108974

Closed
alexey-milovidov wants to merge 1 commit into
masterfrom
play-fix-download-auth
Closed

alexey-milovidov wants to merge 1 commit into
masterfrom
play-fix-download-auth

Conversation

@alexey-milovidov

Copy link
Copy Markdown
Member

Downloading a query result in the Web UI (play.html) failed with:

Code: 516. DB::Exception: Invalid authentication: it is not allowed to use Authorization HTTP header and authentication via parameters simultaneously. (AUTHENTICATION_FAILED)

The download used a hidden <form> POST submit, which cannot set request headers. When the browser had cached Basic-auth credentials, it attached an Authorization header to the submit, which conflicted with the user/password URL parameters the page also adds — so the server rejected the request.

Every other request in the page already avoids this by sending the Authorization: never header via fetch to suppress the cached credentials. This change switches the download to the same mechanism: fetch the result with Authorization: never and save the response blob via an object URL. As a bonus, download errors are now surfaced to the user instead of silently navigating a hidden form.

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Web UI (play.html): fix downloading a result failing with AUTHENTICATION_FAILED (error 516) when the browser holds cached Basic-auth credentials.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

🤖 Generated with Claude Code

Downloading a result in `play.html` failed with:

  Code: 516. DB::Exception: Invalid authentication: it is not allowed to use
  Authorization HTTP header and authentication via parameters simultaneously.
  (AUTHENTICATION_FAILED)

The download used a hidden `<form>` POST submit, which cannot set request
headers. When the browser had cached Basic-auth credentials it attached an
`Authorization` header to the submit, which conflicted with the `user`/`password`
URL parameters the page also adds.

Every other request in the page already avoids this by sending the
`Authorization: never` header via `fetch` to suppress the cached credentials.
Switch the download to the same mechanism: `fetch` the result with
`Authorization: never` and save the response blob via an object URL. Errors are
now surfaced to the user instead of silently navigating the hidden form.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [a3f2052]


AI Review

Summary

The PR fixes play.html downloads when cached Basic-auth credentials conflict with user/password URL parameters by replacing the hidden form submit with a fetch request carrying Authorization: never. The auth direction is consistent with the rest of the page, but the new implementation regresses large result downloads by buffering the entire response before starting the browser download, so I am requesting changes.

Missing context / blind spots
  • ⚠️ The available S3 PR report for a3f20522b90cb14798aaecfebf9b1cc88eee28d1 currently contains Total: 0 test results, so CI does not provide browser-flow evidence for this change.
Findings

⚠️ Majors

  • [programs/server/play.html:5357] Downloading a result should preserve the existing streaming behavior for potentially large ClickHouse outputs. The new await response.blob() path reads the entire response into a browser Blob before starting the file download, so exports that previously streamed directly from the HTTP response can now consume browser memory/temp storage and fail before a file is offered.
    Suggested fix: preserve a streaming download path or add an explicit size/streaming strategy for the fetch path, so the auth fix does not regress large downloads.
Tests
  • ⚠️ No focused browser regression evidence is included for the promised cached Basic-auth scenario. The smallest useful coverage would exercise /play with cached Basic credentials plus user/password parameters and verify that the download request sends Authorization: never and produces a downloadable result.
Final Verdict

Status: ⚠️ Request changes

Minimum required actions: address the large-download buffering regression and add focused browser/manual evidence for the cached Basic-auth download path.

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Jun 30, 2026
Comment thread programs/server/play.html
return;
}

const blob = await response.blob();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ This changes the download contract from a streaming browser download into buffering the whole ClickHouse result inside the page first. await response.blob() only completes after the full response has been read, and only then does the synthetic anchor start the file download; large exports that the previous form path streamed directly to the browser can now consume browser memory/temp storage and fail before the user gets a file.

Please preserve a streaming download path or add an explicit size/streaming strategy for the fetch path, so fixing cached Basic-auth credentials does not regress large result downloads.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

Superseded by #108980, which fixes the root cause on the server side instead. Rather than switching the download to fetch (which would buffer the entire, potentially unbounded, result in memory), the server now lets URL query parameters take precedence over a remembered Authorization header, so the existing streaming form-submit download keeps working. See #108980.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant