Skip to content

Commit 7219e3f

Browse files
authored
DM-51561: Change sync timeout to return a 200 with a VOTable Error instead of the 503 with retry-after (#151)
1 parent d8b28ff commit 7219e3f

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/main/java/org/opencadc/tap/kafka/util/JobPollingService.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,17 @@ public boolean pollAndHandleResults(String jobId, SyncOutput syncOutput)
100100
} catch (JobServiceUnavailableException e) {
101101
// This error is expected to be encountered if we timed out waiting for
102102
// the job to complete, but the job is still in a transient state.
103-
// We return a 503 response to the client with a retry-after header.
104-
log.warn("Job " + jobId + " still processing, returning 503 response");
103+
// We return a VOTable error response with HTTP 200 (traditional DAL approach).
104+
log.warn("Job " + jobId + " still processing, returning VOTable error with 200 status");
105105
try {
106-
syncOutput.setCode(503);
107-
syncOutput.setHeader("Content-Type", "text/plain");
108-
syncOutput.setHeader("Retry-After", String.valueOf(e.getRetryAfterMs() / 1000));
109-
String message = e.getMessage();
106+
syncOutput.setCode(200);
107+
syncOutput.setHeader("Content-Type", "application/x-votable+xml");
108+
//syncOutput.setHeader("Retry-After", String.valueOf(e.getRetryAfterMs() / 1000));
109+
String message = VOTableUtil.generateErrorVOTable(
110+
"Query timeout exceeded for synchronous execution. Please use /async endpoint for long-running queries.");
110111
syncOutput.getOutputStream().write(message.getBytes());
111112
} catch (IOException ioe) {
112-
log.error("Failed to write service unavailable message to output stream", ioe);
113+
log.error("Failed to write timeout error message to output stream", ioe);
113114
}
114115
return false;
115116
}
@@ -404,4 +405,4 @@ private void handleError(SyncOutput syncOutput, int statusCode, String errorMess
404405
log.error("Failed to write error message to output stream", e);
405406
}
406407
}
407-
}
408+
}

0 commit comments

Comments
 (0)