Repository navigation
Send page feedback through the AWS WAF SDK when configured - #4512
Merged
Merged
Conversation
…ts URL The web ACL can require an `aws-waf-token` cookie on `/docs/_api/v1/page-feedback`. A plain `fetch()` cannot solve the challenge. `waf_integration_url` in `config/assembler.yml` now flows into `window.__DOCS_CONFIG__`, and `<page-feedback>` loads that SDK and sends the `PUT` through `AwsWafIntegration.fetch`. With no URL, nothing loads and the call uses plain `fetch()`. If the SDK fails to load, the submit shows the normal error state. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Contributor
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4512/ Sample changed pages: |
…move #4506 replaced YamlDotNet with SharpYaml, so `YamlMember` no longer resolves in `PublishEnvironment`. The merged CI build failed to compile on every OS. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
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.
Page feedback now sends its
PUTthroughAwsWafIntegration.fetchwhen an environment setswaf_integration_url, so it keeps working once AWS WAF requires anaws-waf-tokenon/docs/_api/v1/page-feedback. With no URL, nothing changes.Affects: Site UI, Configuration, Assembler builds
Prompt summary: Make the page feedback call in the docs frontend work once AWS WAF requires a token on that path (elastic/docs-infra#483). Load the WAF JavaScript SDK on pages with
<page-feedback>, configure its URL per environment, fall back to plainfetchwhen unset, and leave every other API call alone.Why
docs-infra#483 adds an opt-in list of API paths that need a valid WAF token. A request without one gets an HTTP 202 challenge that a plain
fetch()cannot solve. Page feedback is the first path on that list, so it fails once the gate turns on unless the frontend calls it through the SDK.What
Per-environment SDK URL
waf_integration_urlon an environment inconfig/assembler.ymlflows throughPublishEnvironment,FeatureFlags.WafIntegrationUrlandFrontendConfigintowindow.__DOCS_CONFIG__.wafIntegrationUrl. It follows the same route aswebsite_search_url. Only non-air-gapped assembler builds set it. Codex, isolated and air-gapped builds always leave it empty. No environment sets a URL in this PR.SDK loading and the
PUTPageFeedback.tsxloads the SDK once, on mount, so the token is usually ready before the first click.submitFeedbackcallsAwsWafIntegration.fetchwhen the SDK is present and plainfetchwhen no URL is configured. The URL, request body, headers and error handling do not change.SDK load failure
A blocked script, a missing
AwsWafIntegrationglobal, or a load that takes longer than 5 seconds rejects the load.submitFeedbackthen throws, and the questionnaire shows its normal error state. It does not fall back to plainfetch, because the challenge response is HTTP 202 andresponse.okwould report success for feedback that was never saved. The next submit retries the load.Out of scope: Nothing in the frontend calls
DELETE /v1/page-feedback/{guid}, so there is nothing to route. Thefeature_search_or_askai_enabledcookie does not exist anywhere in this repo, so there is nothing to remove. Ask AI, search, navigation-search,/changesand the/v1/o/OTLP calls are unchanged. The OTLP calls are browser-only too and could take the same gate later, but they go through the OTEL exporter, notfetch, so they need separate work.Rollout:
waf_integration_urlper environment from the web ACL's application integration URL./docs/_api/v1/page-feedbacktoapi_token_required_path_prefixeson edge, then staging, then prod.Token domain: the docs-infra default
token_domains = ["elastic.co"]coverswww.elastic.co(prod) andstaging-website.elastic.co(staging). It does not cover edge (d34ipnu52o64md.cloudfront.net) or preview (docs-v3-preview.elastic.dev). I expect a token minted oncloudfront.netto be rejected for anelastic.cotoken domain. That is a guess from how AWS scopes token domains, not something I tested. Edge goes first in the rollout, so docs-infra needs to add that host or leavetoken_domainsunset there.Not verified: I did not confirm an
aws-waf-tokenon a real PUT. No WAF-protected environment has an integration URL or a token-required path yet, and I did not run a local stub in a browser. The tests cover the SDK, no-SDK and load-failure paths with a stubbedAwsWafIntegration.Verify