Specify set of valid response content types#6535
Open
mrdziuban wants to merge 2 commits into
Open
Conversation
Fixes canton-network#6483. This updates `HttpClient.createHttpFn` to consider a response invalid if its content type is not `application/json`, `application/octet-stream`, or `text/plain`. This results in `httpClientWithErrors` calling `getApiErrorFromResponse`, which produces an `HttpCommandException` and includes the raw response body in its error message. These three content types are the only ones used across all the OpenAPI specs in the repo. `text-plain` is used by [`devNetOnboardValidatorPrepare`](https://github.com/canton-network/splice/blob/main/apps/sv/src/main/openapi/sv-internal.yaml#L506-L508), and `application/octet-stream` is used by [`bulkStorageDownload`](https://github.com/canton-network/splice/blob/main/apps/scan/src/main/openapi/scan-stream-server.yaml#L46-L50). Signed-off-by: Matt Dziuban <mrdziuban@gmail.com>
mrdziuban
force-pushed
the
mrdziuban/non-json-responses/6483
branch
from
July 24, 2026 17:01
5d8b6e4 to
cc39057
Compare
Author
|
Pushed another commit (and updated the PR description) to also allow responses with |
Signed-off-by: Matt Dziuban <mrdziuban@gmail.com>
mrdziuban
force-pushed
the
mrdziuban/non-json-responses/6483
branch
from
July 24, 2026 20:15
1210be8 to
eaf6e38
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6483
This updates
HttpClient.createHttpFnto consider a response invalid if its content type is notContentTypes.NoContentType,application/json,application/octet-stream, ortext/plain. This results inhttpClientWithErrorscallinggetApiErrorFromResponse, which produces anHttpCommandExceptionand includes the raw response body in its error message.ContentType.NoContentTypeis used for responses with no content type specified, like this, and the other three content types are the only ones used across all the OpenAPI specs in the repo.text/plainis used bydevNetOnboardValidatorPrepare, andapplication/octet-streamis used bybulkStorageDownload.Note that this allowlist approach does present a risk of future issues if a new endpoint is added using a different content type. A blocklist approach (e.g. only considering
text/htmlinvalid) would prevent this issue, but would capture fewer invalid responses.Pull Request Checklist
Cluster Testing
/cluster_teston this PR to request it, and ping someone with access to the DA-internal system to approve it./upgrade_teston this PR to request it, and ping someone with access to the DA-internal system to approve it./hdm_teston this PR to request it, and ping someone with access to the DA-internal system to approve it./lsu_teston this PR to request it, and ping someone with access to the DA-internal system to approve it.PR Guidelines
Fixes #n, and mention issues worked on using#nMerge Guidelines