Add includeExperimental flag to experimental endpoint code samples#128
Merged
Merged
Conversation
Endpoints marked with `x-glean-experimental` require the SDK's experimental opt-in (surfaced as the `X-Glean-Include-Experimental` request header), or the SDK refuses to call them. The generated samples for these operations were missing this, so they would not actually run as-is. Adds `addIncludeExperimentalToCodeSamples` (run after `addServerURLToCodeSamples`) which injects the flag per language: - Python: `include_experimental=True,` - TypeScript: `includeExperimental: true,` - Go: `apiclientgo.WithIncludeExperimental(true),` - Java: swaps `Glean.builder()` for the regen-safe `GleanBuilder.create()` (adding its import) and appends `.includeExperimental(true)` A new `experimentalCodeSnippets` generator ensures only operations carrying `x-glean-experimental` are touched. Adds a dedicated fixture and tests covering all four languages plus a guard that non-experimental samples are untouched.
chris-freeman-glean
approved these changes
Jul 8, 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.
Summary
Endpoints marked with
x-glean-experimentalrequire the SDK's experimental opt-in (surfaced as theX-Glean-Include-Experimentalrequest header). Without it, the SDKs refuse to call the endpoint — so the generated code samples for these operations don't actually run as-is.This adds a post-processing transform that injects the experimental opt-in into the code samples for experimental endpoints only.
Changes
experimentalCodeSnippets(pathSpec)— generator that yields samples only for operations carryingx-glean-experimental.addIncludeExperimentalToCodeSamples(spec)— injects the flag per language, wired intotransform()to run afteraddServerURLToCodeSamples(so the server-URL constructor line exists to anchor onto):include_experimental=True,after theserver_urllineincludeExperimental: true,after theserverURLlineapiclientgo.WithIncludeExperimental(true),afterWithServerURLGlean.builder()→ the regen-safeGleanBuilder.create()(adding its import) and appends.includeExperimental(true)after.apiToken(...)Notes
GleanBuilder.create()because the generatedGlean.builder()isn't guaranteed to exposeincludeExperimental. Since platform Java samples never carry aserverURLline, the Java edit anchors on.apiToken(...)instead.merged_code_samples_specs/glean-platform-merged-code-samples-spec.yaml: all four/api/agents/searchsamples correctly gain the flag, and there are zero leaks into non-experimental samples.Testing
tests/fixtures/example-with-experimental-code-samples.yaml(one experimental + one stable endpoint).