Repository navigation
Harden the docs API error paths and drop dead startup code - #4894
Merged
Merged
Conversation
akira28
force-pushed
the
fix/docs-api-hardening
branch
from
November 17, 2026 14:40
60bcb42 to
4cc921a
Compare
akira28
changed the base branch from
main
to
feature/api-operations-rest-endpoints
November 17, 2026 14:40
Contributor
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4894/ |
akira28
force-pushed
the
fix/docs-api-hardening
branch
from
November 17, 2026 16:20
b4ee6a4 to
7c011a2
Compare
Base automatically changed from
feature/api-operations-rest-endpoints
to
main
November 18, 2026 09:19
akira28
force-pushed
the
fix/docs-api-hardening
branch
from
November 18, 2026 09:19
069fae6 to
a76316a
Compare
A search backend that is temporarily unavailable now answers 503 with Retry-After, and every unhandled error has a JSON body. /search clamps page and size once in FullSearchService. Ask AI message feedback answers 503 when it could not be stored. The Ask AI activity sources are created once, and the stream activity ends when the call throws. Startup no longer builds the service provider to log, and the unused parameter providers, validator and named HTTP client are gone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The gateway test drives the real gateway through an in-memory transport, so returning true on a failed write fails it. The stream tests fail AskAi and the transformer in turn and check the chat activity was ended with an error; without the handler's catch, the activity is never exported. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every factory's listener sees every Ask AI span in the process, so EuidEnrichmentTests could read the span of a parallel AskAiStreamFailureTests run, which has no euid. Co-Authored-By: Claude Opus 5.5 <[email protected]>
akira28
force-pushed
the
fix/docs-api-hardening
branch
from
November 18, 2026 09:38
a76316a to
12207a5
Compare
reakaleek
approved these changes
Nov 18, 2026
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 six small problems in the docs API (
Elastic.Documentation.Api). Each one is either a bug a client can hit or code that does nothing. A temporarily unavailable search backend now answers 503 withRetry-Afterinstead of an empty 500./searchcan no longer pass an unbounded page size to Elasticsearch. Failed Ask AI feedback is no longer reported as stored.Affects: API, MCP
Closes: elastic/docs-eng-team#1206
Prompt summary: Review the whole docs API for refactoring opportunities, then fix the small, safe findings in one follow-up PR, separate from the API operations work in #4887.
Why
A review of the API during #4887 found these. They are independent of that PR and of each other, and each is small.
What
Errors
SearchUnavailableException(a timeout or an overloaded cluster) into a 503 withRetry-After: 5, and logs it as a warning.{ "errorType", "message" }, a newApiErrorrecord inApiJsonContext. The 500 message does not include exception details.The MCP server already treated
SearchUnavailableExceptionas retryable; the API did not.Search limits
FullSearchServiceclampspageto at least 1 andsizeto 1–50 before it queries the index. Before,/search?size=0orsize=100000reached Elasticsearch and came back as a 500.Both the API and MCP go through
FullSearchService, so the MCP tool's own clamp is removed. The site's largest page size is 50.Ask AI
IAskAiMessageFeedbackService.RecordFeedbackAsyncreturns whether the write succeeded, likeIPageFeedbackService. The endpoint answers 503 when it did not; before, it returned 204 and the feedback was lost.ActivitySourceon every request and never disposed it, so each one stayed registered for the life of the process. They are nowstatic readonly, as in the stream transformers and the cache.Startup and dead code
GetLogger: it built the whole service provider (four times in the API, once in the search project) only to log "registered successfully" messages, inside try/log/rethrow blocks. It is gone. The one useful message, an unknown environment name, now goes to the console like the rest of startup.IParameterProviderand its Lambda and local implementations (a comment already marked them for removal), the test fake for it, the unreferencedValidation/IValidator, and the named"StreamingHttpClient".HttpClient. Its 10-minute timeout never applied, so removing it changes nothing.Tests for the fixes
AskAiMessageFeedbackGatewayTestsdrives the real gateway through an in-memory transport with 200, 201, 400 and 503 responses.AskAiStreamFailureTestsmakesAskAiand then the transform throw, and checks the chat activity was ended with anErrorstatus. Removing the handler's cleanup fails both cases.AskAiStreamFailureTests,EuidEnrichmentTests) share aNotInParallelkey.Verify
All three pass locally (282, 76 and 87 tests).
Out of scope: one error format for every endpoint and typed results. Those fit with the OpenAPI spec in elastic/docs-eng-team#1205.
Stack: second layer of #4895, on top of #4887. #4896 builds on it.
🤖 Generated with Claude Code