Skip to content

Send page feedback through the AWS WAF SDK when configured - #4512

Merged
reakaleek merged 5 commits into
mainfrom
page-feedback-waf-token-940f15df
Oct 22, 2026
Merged

reakaleek merged 5 commits into
mainfrom
page-feedback-waf-token-940f15df

Conversation

@reakaleek

Copy link
Copy Markdown
Member

Page feedback now sends its PUT through AwsWafIntegration.fetch when an environment sets waf_integration_url, so it keeps working once AWS WAF requires an aws-waf-token on /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 plain fetch when 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_url on an environment in config/assembler.yml flows through PublishEnvironment, FeatureFlags.WafIntegrationUrl and FrontendConfig into window.__DOCS_CONFIG__.wafIntegrationUrl. It follows the same route as website_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 PUT

PageFeedback.tsx loads the SDK once, on mount, so the token is usually ready before the first click. submitFeedback calls AwsWafIntegration.fetch when the SDK is present and plain fetch when no URL is configured. The URL, request body, headers and error handling do not change.

SDK load failure

A blocked script, a missing AwsWafIntegration global, or a load that takes longer than 5 seconds rejects the load. submitFeedback then throws, and the questionnaire shows its normal error state. It does not fall back to plain fetch, because the challenge response is HTTP 202 and response.ok would 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. The feature_search_or_askai_enabled cookie does not exist anywhere in this repo, so there is nothing to remove. Ask AI, search, navigation-search, /changes and 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, not fetch, so they need separate work.

Rollout:

  1. Merge this PR with no URL set.
  2. Set waf_integration_url per environment from the web ACL's application integration URL.
  3. docs-infra adds /docs/_api/v1/page-feedback to api_token_required_path_prefixes on edge, then staging, then prod.

Token domain: the docs-infra default token_domains = ["elastic.co"] covers www.elastic.co (prod) and staging-website.elastic.co (staging). It does not cover edge (d34ipnu52o64md.cloudfront.net) or preview (docs-v3-preview.elastic.dev). I expect a token minted on cloudfront.net to be rejected for an elastic.co token 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 leave token_domains unset there.

Not verified: I did not confirm an aws-waf-token on 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 stubbed AwsWafIntegration.

Verify

cd src/Elastic.Documentation.Site && npm run test -- PageFeedback
./build.sh unit-test

…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]>
@reakaleek
reakaleek requested a review from a team as a code owner October 19, 2026 13:08
@reakaleek
reakaleek requested a review from akira28 October 19, 2026 13:08
@github-actions

Copy link
Copy Markdown
Contributor

reakaleek and others added 4 commits October 22, 2026 07:56
…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]>
@reakaleek
reakaleek merged commit c1a40c8 into main Oct 22, 2026
32 checks passed
@reakaleek
reakaleek deleted the page-feedback-waf-token-940f15df branch October 22, 2026 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant