[OPIK-5619] [BE] fix: add workspace-wide fallback header for dataset item streaming#6060
Merged
thiagohora merged 6 commits intomainfrom Apr 2, 2026
Conversation
…reaming When an old SDK sends a wrong project_name (e.g. "Default Project") to the stream-items endpoint, the backend now finds the dataset via workspace-wide search and returns the correct items. The X-Opik-Deprecation header is also emitted on streaming responses (ChunkedOutput) when the fallback is triggered. Key changes: - DatasetService: add blocking resolveDatasetByName that sets the fallback header on the HTTP request thread; rename reactive variant to resolveDatasetByNameAsync and remove the invalid requestContext.get() call inside Mono.fromCallable - DatasetItemService: updated streaming getItems to use resolveDatasetByNameAsync; interface no longer carries Visibility (read from reactor context instead) - DatasetsResource.streamDatasetItems: call blocking resolveDatasetByName first (sets fallback message), then inject HttpServletResponse to emit X-Opik-Deprecation header before ChunkedOutput is committed; capture RequestContext eagerly to avoid Guice OutOfScopeException inside contextWrite - AsyncUtils: add setRequestContext(Context, RequestContext) overload that accepts an already-resolved RequestContext object - Tests: add streamDataItems__whenNonExistingProjectName__thenReturnDeprecationHeader to verify the header is sent on streaming responses
Contributor
Backend Tests - Integration Group 15 25 files ±0 25 suites ±0 4m 44s ⏱️ -6s For more details on these errors, see this check. Results for commit e9fec2f. ± Comparison against base commit 7511a9a. |
ldaugusto
reviewed
Apr 2, 2026
Contributor
ldaugusto
left a comment
There was a problem hiding this comment.
Minor things to tackle
2 tasks
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.
Details
When old SDK versions send a wrong
project_name(e.g."Default Project") to thestreamDatasetItemsendpoint, the backend should still find the dataset via workspace-wide fallback and emit theX-Opik-Deprecationheader — the same deprecation signal already emitted on non-streaming endpoints.Changes:
resolveDatasetByName(DatasetIdentifier)toDatasetService(safe to call on the HTTP thread) that sets the workspace fallback message on the request context when the project name was given but couldn't be resolved.resolveDatasetByNameAsyncand cleaned it up to readworkspaceId/visibilityfrom reactor context viaMono.deferContextual(avoids GuiceOutOfScopeExceptiononboundedElasticthreads).streamDatasetItemsinDatasetsResourcenow (1) eagerly capturesRequestContextbefore any lambdas, (2) calls the blockingresolveDatasetByNameto trigger the fallback check, (3) injectsHttpServletResponseto set theX-Opik-Deprecationheader synchronously before returning theChunkedOutput.AsyncUtils.setRequestContext(Context, RequestContext)overload that accepts an already-resolvedRequestContextobject, socontextWritecan safely use values captured on the HTTP thread without calling the Guice-scopedProviderinside a reactive lambda.DatasetItemService.getItemssignature (removed the redundantVisibilityparameter — now read from reactor context inside the service).X-Opik-Deprecationheader on streaming when a non-existingproject_nameis provided.Change checklist
Issues
AI-WATERMARK
AI-WATERMARK: yes
Testing
Scenarios validated:
project_nameworks as before (15 existingStreamDatasetItemstests pass)project_namereturns items (workspace-wide fallback) + emitsX-Opik-Deprecationheader (new test)Documentation
N/A — internal fallback behavior, no user-facing API surface changes.