Repository navigation
test(e2e): disable ETag conditional reads for Playwright runs - #30239
chirag-madlani merged 1 commit into
Conversation
The server ETag is hash(version + "-" + updatedAt), so it does not change for relationship-only or child mutations (followers, votes, customMetrics, testSuite). A refetch that races such a mutation is answered "not modified" and the UI renders a stale body, which surfaces as flaky assertions across the AUT suite (UpVote/DownVote, Follow/Un-follow, FollowingWidget, Tags, CustomMetric, TestSuiteMultiPipeline, ...). Opt E2E sessions out of client-side conditional reads: - Export DISABLE_ETAG_CONDITIONAL_READS_KEY and skip attachEtagInterceptor when the flag is set, guarded for non-browser contexts. - Set the flag in auth.setup.ts before each storageState write, so it persists via storageState and is inherited by every spec in both OpenMetadata and Collate without a per-test helper. - Drop the now-redundant forceFreshTableReads helper and its call sites. This is a containment for the test suite; the ETag itself should still be fixed to reflect the requested fields and child state. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
Code Review ✅ ApprovedDisables ETag conditional reads for E2E tests by persisting a global flag in OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
|
🔴 Playwright Results — 2 failure(s), 37 flaky✅ 4528 passed · ❌ 2 failed · 🟡 37 flaky · ⏭️ 99 skipped
Genuine Failures (failed on all attempts)❌
|
…key (open-metadata#30292) open-metadata#30239 added a localStorage flag so E2E sessions skip client-side conditional (If-None-Match) reads, but auth.setup.ts imported the key across the playwright -> src boundary: import { DISABLE_ETAG_CONDITIONAL_READS_KEY } from '../../src/rest/etagInterceptor'; That import resolves to undefined at runtime, so setup executed localStorage.setItem(undefined, 'true') and the flag was persisted under the literal key "undefined". The app then read the real key, got null, attached the interceptor anyway, and the opt-out was a silent no-op in every run — AUT still showed the stale-read failures it was meant to fix. Inline the key literal instead, with a comment tying it to the app-side constant. Verified locally against a build containing the guard: repeat table GETs now return full bodies with zero If-None-Match headers (previously 2 of 7 GETs came back with If-None-Match and bodySize 0). Flag confirmed readable at module-init timing for all 8 roles, on both the OpenMetadata and Collate playwright setups. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* test(e2e): strip ETag If-None-Match at the network layer The localStorage opt-out from #30239/#30292 only works when the running UI bundle contains the interceptor guard. In the upgrade AUT (1.11.13 -> main) the served bundle does not evaluate the guard, so the client still sends If-None-Match, the server answers 304, and the UI renders a stale body — the flaky-assertion source persists. Strip the If-None-Match header on /api/v1/** at the Playwright network layer instead. This sits below the app, so it works regardless of which bundle runs or whether its guard fires: the server always receives an unconditional GET and returns the current body. Installed once per page (WeakSet-guarded) from redirectToHomePage, which every affected spec routes through (createNewPage calls it too). Kept alongside the existing localStorage opt-out as defense in depth. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * test(e2e): also install the ETag strip in the page fixtures redirectToHomePage covers specs that call it, but ~79 specs get their page from the fixtures/pages and support/fixtures/userPages fixtures without going through it. Install stripEtagConditionalReads on those role pages too, so fixture-based specs get fresh entity reads regardless of the deployed bundle. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * test(e2e): strip If-None-Match on specs using raw page fixtures The network-layer ETag strip was reached via redirectToHomePage and the role fixtures. These specs bypass both — the 3 Glossary status-filter specs use the built-in `page` fixture (navigating in their own beforeEach) and SearchRBAC creates raw `browser.newPage()` contexts. Install stripEtagConditionalReads directly at those page-acquisition points so every failing spec is reachable by the fix regardless of how it obtains its page. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>



Problem
A large share of AUT failures share one root cause: the ETag doesn't move when the response body does.
EntityETag.generateETag()ishash(version + "-" + updatedAt). Relationship-only and child mutations —addFollower,removeFollower,updateVote,customMetric, the executabletestSuite— do not bump the parent'sversion/updatedAt. So after such a write the ETag is unchanged, the client's conditional refetch (If-None-Match,etagInterceptor.ts) is answered "not modified", and the UI renders a stale body.Confirmed from a failing trace:
PUT /tables/{id}/customMetricreturned the table withcustomMetrics: 1atversion 0.1/updatedAt 1784239349138. The very next table GET carriedIf-None-Match, came back with no body, and the UI rendered the cached copy withcustomMetrics: 0— sameversion/updatedAt, therefore identical ETag.fields: afields=testSuiterequest and afields=customMetrics,columnsrequest produce the same ETag, so one can be served the other's body.ETagResponseFilter's own Javadoc names this hazard foraddFollower/removeFollower/updateVote— matching theUpVote & DownVote(1→0) andFollow & Un-follow(Unfollow→Follow) failures seen in AUT.It's load-dependent: the interceptor clears its cache on every mutation, so normally the refetch is unconditional. Under load a refetch dispatched around the mutation still carries a stale
If-None-Match, so it fires often on slow AUT runs and almost never locally.Change
Opt E2E sessions out of client-side conditional reads:
DISABLE_ETAG_CONDITIONAL_READS_KEYand skipattachEtagInterceptorwhen it is set (guarded withtypeof localStorage === 'undefined'for non-browser contexts).auth.setup.tsbefore eachstorageState()write, so it persists via storageState and is inherited by every spec — no per-test helper, and it covers both OpenMetadata and Collate (both run off the samesetupproject).forceFreshTableReadshelper and its call sites.Why storageState rather than a fixture or a shared helper: 99/341 OM specs (and 71/130 Collate specs) never call
redirectToHomePage, and 69 specs importteststraight from@playwright/test, so neither a helper nor a fixture reaches full coverage without touching dozens of files.Validation
playwright/.auth/admin.json, confirming it persists via storageState.CustomMetric.spec.tspasses with the per-test helper removed — the global flag does the work.TestSuiteMultiPipeline.spec.tsfails locally at an unrelated step (the test-case drawer'sEnter a Countfield). Verified against a clean baseline with these changes stashed — it fails identically, so it is pre-existing in this environment (@ingestion-tagged, needs Airflow) and not caused by this change.tsc --noEmitreports nothing on the touched files.Follow-up
This is containment for the test suite. The ETag itself should still be fixed so it reflects the requested
fieldsand child state — e.g. foldfieldsinto the ETag, skip ETag/304 for GETs carrying child-resolved fields, or stamp child changes onto the parent. Happy to split that into a separate PR.🤖 Generated with Claude Code
Greptile Summary
This PR disables conditional ETag reads for Playwright sessions. The main changes are:
Confidence Score: 5/5
This looks safe to merge.
Important Files Changed
Reviews (1): Last reviewed commit: "test(e2e): disable ETag conditional read..." | Re-trigger Greptile
Context used (3)