Skip to content

fix: add terminal failure handler to URL transcode Future chain - #1729

Open
waterWang wants to merge 2 commits into
unitycatalog:mainfrom
waterWang:fix/transcoder-failure-handler
Open

waterWang wants to merge 2 commits into
unitycatalog:mainfrom
waterWang:fix/transcoder-failure-handler

Conversation

@waterWang

Copy link
Copy Markdown

Problem

URLTranscoderVerticle builds its response inside a Future chain that has no terminal failure handler, so any failure in that chain leaves the request unanswered and the client waits until it times out.

The chain is transcodeRequest.body().compose(...).compose(...) at server/src/main/java/io/unitycatalog/server/URLTranscoderVerticle.java. If either stage fails, for example because the request to the Armeria backend cannot be made, nothing writes to transcodeRequest.response() and the connection stays open.

Fix

Add an .otherwise() handler to the Future chain that:

  1. Logs the error
  2. Sets a 502 status code
  3. Ends the response with the error message
  4. Checks headWritten() to avoid double-write in edge cases

Fixes #1717

@yili-db yili-db changed the title fix: add terminal failure handler to URL transcode Future chain (#1717) fix: add terminal failure handler to URL transcode Future chain Jul 29, 2026
Comment thread api/all.yaml
type: string
maxLength: 65536
minLength: 1
minLength: 0

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This seems to belong to another PR

});
}
}
} No newline at end of file

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please do not remove new line at end of file

if (!transcodeResp.headWritten()) {
transcodeResp.setStatusCode(502);
transcodeResp.putHeader("Content-Type", "text/plain");
transcodeResp.end("Backend error: " + err.getMessage());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

err.getMessage may leak internal info. Something like transcodeResp.end("Backend request failed"); is safer.

@yili-db yili-db left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Needs a test for the new failure path. The existing URLTranscoderVerticleTest is already set up for this — deploy a transcoder pointed at a dead backend port (use findAvailablePort() for a port with nothing listening) and assert the request returns 502 instead of hanging. The bounded .get(TIMEOUT_SECONDS, ...) in send(...) means a regression fails as a timeout.

Thank you!

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

URL transcoder leaves the request unanswered when the backend call fails

2 participants