Repository navigation
Fixes 31735: stop Playwright support classes swallowing failed API responses - #31736
Conversation
Support classes assigned `await response.json()` onto their `responseData` without checking the response first. On a non-2xx the *error* body became the entity's state: `id` and `fullyQualifiedName` vanished, nothing threw, and the run broke much later somewhere unrelated. Traces from four EKS nightly runs show this end to end. In PlatformLineage a 409 race on fixture creation is recovered correctly, then the follow-up domain PATCH returns 400, the error body overwrites the table, and the empty FQN sends `visitEntityPage` down its search branch with an empty search term - which fires no request, so an unrelated `waitForResponse` burns its full 30s. In NotificationTemplate, POST /policies and POST /roles both 409, the error bodies land on `responseData`, and the subsequent user PATCH sends an undefined role id and gets a 500 - so the permission never applies and the assertion fails. Add two shared helpers in playwright/utils/apiResponse.ts: - `okJson` throws with the status and body instead of returning an error payload. Applied to the 107 create/patch reads that were unguarded. Cleanup deletes are deliberately left alone, since a 404 there means "already gone". - `createOrFetch` treats 409 as success and fetches the existing entity by name, matching the helper already in TableClass. Applied to the collections that actually 409ed across 113 traces: policies (8), roles (8), databaseServices (16), databases (5), databaseSchemas (5), tables (4) and glossaries. The server itself was never slow - across those 113 traces only 2 had any API call over 3s, and the median per-trace worst case was 422ms. These waits were dead waits, not slow responses. Verified: `tsc -p playwright/tsconfig.json` error set is unchanged from origin/main (163 before, 163 after; zero introduced once import line-shifts are normalised), and the CI lint sequence is idempotent with 0 errors. Co-Authored-By: Claude Opus 5 <[email protected]>
The method tracker used to decide which `.json()` reads to guard also matched `if (`, `for (` and `while (`, so tracking broke at the first conditional inside a method and every later read in that method was skipped. Five sites slipped through, including `TableClass.patch` - the exact call whose 400 response corrupts the table entity and sends PlatformLineage into a 30s dead wait, which is the failure this change exists to fix. Also repairs the import block in GlossaryTerm.ts: the insertion put the new import inside a multi-line import, which broke parsing for the whole project. Verified again: `tsc -p playwright/tsconfig.json` is 163 before and 163 after with zero introduced and zero removed, the lint sequence is idempotent, and no delete/cleanup path is guarded (112 okJson sites: 61 create, 42 patch, 9 misc). Co-Authored-By: Claude Opus 5 <[email protected]>
…ng entity
The 409 adoption path fetched the existing entity with a bare
`GET .../name/<fqn>`. The API answers `null` for every field the caller did not
ask for, so an adopted table reported `domains: null` even though a domain was
already attached - the trace shows exactly that, `domains: null` on a table at
version 0.2. The caller then re-applied its own `add /domains/0` and the server
rejected it:
{"code":400,"errorType":"RULE_VIOLATION",
"message":"Rule [Multiple Domains are not allowed] validation failed ..."}
So adoption was handing back an entity that looked untouched purely because the
lookup never asked, which is what made the follow-up patch fail. TableClass now
requests `fields=domains,owners,tags`, and `createOrFetch` takes an optional
`fields` so other callers can do the same.
The default stays "no fields" deliberately: `fields` is validated per collection
and an unknown name is a 400. `policies` allows only owners,location,teams,roles
and `roles` only policies,teams,users, so a blanket default would have broken
adoption for exactly the two collections this change set out to fix.
Verified: tsc unchanged from origin/main (163/163, zero introduced), lint clean.
Note this does not by itself make PlatformLineage pass - the caller must also
stop re-adding a domain it can now see is present. That is 25 inline
`path: '/domains/0'` sites, some of which legitimately add a second domain to a
User or Team, so it needs its own change rather than a blanket rewrite.
Co-Authored-By: Claude Opus 5 <[email protected]>
`op: 'add', path: '/domains/0'` appends. On a data asset the server allows only
one domain, so the op succeeds on a fresh entity and fails on one that already
has a domain:
{"code":400,"errorType":"RULE_VIOLATION",
"message":"Rule [Multiple Domains are not allowed] validation failed ..."}
That is what a worker hits after losing a create race: it adopts the entity the
winner already configured, then re-applies its own domain. Switching to
`path: '/domains'` with an array value sets the field instead of appending, so
the same assignment lands the same way whether the entity was just created or
adopted. `domainIsolationUtils.ts` already patched tables this way, so the form
is established.
56 ops across 25 files. The four `testUser` sites are deliberately left on
`/domains/0`: Users and Teams are the documented exception to the single-domain
rule, and appending is the behaviour those tests want.
With this, the PlatformLineage chain closes end to end - 409 on the fixtures is
absorbed by createOrFetch, the adoption lookup now reports the existing domain,
and the domain assignment no longer conflicts, so the empty search term and its
30s dead wait never happen.
Verified: tsc unchanged from origin/main (163/163, zero introduced), lint 0
errors and idempotent, and only the intended path/value lines differ - the
matching id/name lines in the diff are prettier re-indentation.
Co-Authored-By: Claude Opus 5 <[email protected]>
…ty classes
Widens 409 tolerance from the collections that were observed failing to every
service class plus the entity classes whose fixture shape is unambiguous:
all ten `*ServiceClass` files, and Topic, Chart, MlModel, SearchIndex, Metric.
That brings 22 of 47 creating classes onto the shared helper.
FQNs are declared per collection rather than inferred. A wrong FQN turns a
recoverable 409 into a hard "failed to fetch existing", so nothing here is
guessed: services are top level (`entity.name`), the five entity classes hang
off a service (`${service.name}.${entity.name}`) which their own payloads
confirm, and every target's `GET .../name/{fqn}` endpoint was checked against
its Java resource.
Left on raw POST deliberately, because the lookup is not a plain name-addressed
create and a bad guess is worse than the status quo: BundleTestSuite (deploy and
trigger endpoints, not entity creation), Task, UserClass (`/users/signup`, whose
lookup lives on a different path), Alert, KnowledgeCenter, LearningResource, and
the multi-child builders (Dashboard, Container, ApiCollection, ApiEndpoint,
StoredProcedure, the Drive chain, Tag, GlossaryTerm, SubDomain, DataProduct,
Team, Bot, Persona, Classification). None of these 409ed in the 113 traces.
Verified: tsc unchanged from origin/main (163/163, zero introduced, zero
removed), eslint 0 errors, and every `delete()` in the five entity classes is
byte-identical to main — an earlier global replace had silently rewritten their
returns and orphaned a declaration.
Co-Authored-By: Claude Opus 5 <[email protected]>
Found by running the converted classes against a live 2.0.0-SNAPSHOT server:
Domain.create adopted nothing and failed outright.
Domain.create: fetch existing "PW%domain.1e518933" failed (404):
{"code":404,"message":"domain instance for PW%domain.1e518933 not found"}
Domain names are generated as `PW%domain.${uuid}`, and `.` separates FQN
segments, so the adoption lookup asked for a two-segment FQN that does not
exist. Confirmed directly against the server: the unquoted name 404s, the quoted
form returns 200.
Add `quoteFqnSegment` and use it for the Domain lookup. Of the classes now on
createOrFetch only Domain generates a dotted name, but the helper is exported so
DataProduct and SubDomain can use it when they are converted.
This was exactly the failure mode the conservative scoping was meant to avoid -
a wrong FQN turning a recoverable 409 into a hard error - and it shipped anyway
in the one class where the name carried a separator. Static checks could not see
it; only executing the code did.
Verified by running the real support classes against the server: adoption on 409
now succeeds for DatabaseService, MessagingService, Topic, Policy, Role and
Domain, and okJson raises status plus body on a 404. tsc unchanged from
origin/main (163/163), eslint 0 errors.
Co-Authored-By: Claude Opus 5 <[email protected]>
…utomatic
Quoting one call site was the wrong shape: the next fixture name that happens to
contain a separator would break the same way, silently. Move composition into the
helper instead.
- `quoteFqnSegment` now mirrors the server exactly. `FullyQualifiedName.quoteName`
escapes an embedded quote by doubling it (`"` -> `""`); the previous version
backslash-escaped it, which was wrong for any name containing a quote.
- `buildFqn(...segments)` quotes each raw name and joins them.
- `createOrFetch` takes `fqnSegments: string[]` rather than a pre-built string, so
no call site knows the escaping rules. All 25 sites converted.
- TableClass's own helper composed lookups as `${parent.fullyQualifiedName}.${name}`.
The parent was escaped but the appended name was not, so it had the same latent
bug; it now builds from raw names through `buildFqn` too.
Validated against a running server, including the case that would previously have
slipped through — a table whose own name carries a separator, created and then
adopted at full FQN depth:
quoteFqnSegment('has.dot') -> "has.dot"
quoteFqnSegment('has"quote') -> "has""quote"
buildFqn('svc','has.dot','leaf') -> svc."has.dot".leaf
7/7 checks pass: adoption on 409 for DatabaseService, MessagingService, Topic,
Policy, Role, Domain and a dotted-name Table, plus okJson raising status and body.
tsc unchanged from origin/main (163/163), eslint 0 errors.
Co-Authored-By: Claude Opus 5 <[email protected]>
❌ 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 |
🔴 Playwright Results — workflow failedValidated commit ✅ 1009 passed · ❌ 1 failed · 🟡 4 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ❌ unmet · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 55m 31s ⏱️ Max setup 5m 0s · max shard execution 20m 22s · max shard-job elapsed before upload 23m 41s · reporting 19s 🌐 211.42 requests/attempt · 2.43 app boots/UI scenario · 25.78% common-shard skew Optimization targets still in progress:
Genuine Failures (failed on all attempts)❌
|
The guard did its job — every CI failure was a latent bug it exposed, not a new
one. Four distinct causes, from the run's traces:
1. `SubDomain.create failed (404): domain instance for PW%domain.dc7e6578 not
found` (3 tests). SubDomain sends `parent: responseData.fullyQualifiedName ??
data.name`, and the fallback passed the raw dotted name, which the FQN parser
reads as two segments. Quote it. Pre-existing; the 404 used to be swallowed and
the test carried on with a subdomain that was never created.
2. `PoliciesClass.create failed (400): EL1004E: Method hasDomain(java.lang.String)
cannot be found` (4 tests). `RuleEvaluator.hasDomain()` takes no arguments, but
DomainAdvanced.spec.ts passed the domain FQN to it. Also pre-existing (same on
origin/main), so that policy has never once been created and the test asserted
against permissions it never applied. Drop the argument.
3. `DataProduct.addAssets failed (400)` with `numberOfRowsFailed: 1` and a
`failedRequest` list. That is the bulk endpoint's partial-failure report, not a
transport error, so the caller is meant to read the body. Reverted to a plain
`.json()` for that one method.
4. `SpreadsheetClass.create failed (409)`. Exactly the case the earlier scoping
left on raw POST, and it surfaced on the first CI run. Converted to
createOrFetch.
Validated against a running server (4/4): a subdomain now resolves its dotted
parent, SpreadsheetClass adopts on 409, `hasDomain()` is accepted, and
`hasDomain('x')` still rejects with EL1004E so the fix is aimed at the real cause.
tsc unchanged from origin/main (163/163), eslint 0 errors.
Co-Authored-By: Claude Opus 5 <[email protected]>
A nightly AUT shard recorded POST /policies answering 201, POST /roles referencing that exact policy id answering 404 "policy instance ... not found" 15ms later, and DELETE of the same id answering 200 a further 58ms on. The row was committed throughout; only the reference lookup lagged, so the create had no reason to fail the try. createOrFetch now retries a 404 up to three times with a widening delay before giving up. Also route PersonaClass and ClassificationClass through createOrFetch -- both were guarded but not 409-tolerant, and both surfaced as flaky with "Entity already exists" in the same run.
The mirror of the create-side race, seen in the same AUT run as "ApiServiceClass.patch failed (404): apiService instance ... not found" against the id its own create had just returned. A 404 means the request was rejected outright, so nothing was partially applied and re-sending is safe. withNotFoundRetry wraps all 41 apiContext.patch call sites across the support classes. Wrapping rather than rewriting each body keeps every site's existing okJson label and downstream handling untouched.
createRole.policies is an array of entityName, so the server resolves each entry by name. Pagination's Roles setup passed policy.responseData.id, so every role create answered 404 "policy instance for <uuid> not found" -- deterministically, not as a race: a trace shows all four attempts failing 1.8s apart while DELETE /policies/<that id> succeeds 38ms later. Every other RolesClass.create call site already passes .name or .fullyQualifiedName; this was the lone outlier.
Seven describe blocks seeded entities and never removed them: metrics, notification alerts, observability alerts, roles, policies, bots, and the tasks pipeline. Every block that did clean up was deleting a parent service and relying on the cascade, so the top-level types -- which have no parent -- leaked ~140 rows per run into the list endpoints other specs read. The roles teardown runs before the policy it references.
Code Review ✅ ApprovedUpdates Playwright support classes to validate API responses and adopt existing entities on 409 conflicts, addressing swallowed failed responses. No issues found. OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
Describe your changes:
Fixes #31735
Support classes assigned
await response.json()ontoresponseDatawithout checking the response, so on a non-2xx the error body became the entity's state —idandfullyQualifiedNamegone, nothing thrown, and the run broke much later somewhere unrelated. Traces from four EKS nightly runs show a failed PATCH surfacing as a 30swaitForResponsetimeout several steps downstream.Four changes, smallest blast radius first:
okJson— throws with status + body instead of returning an error payload. Applied to the 94 create/patch reads that were unguarded. Cleanup deletes are deliberately left tolerant, since a 404 there means "already gone".createOrFetch— treats 409 as success and fetches the existing entity. Extended from the collections observed failing to all ten*ServiceClassfiles plus Topic, Chart, MlModel, SearchIndex, Metric — 27 of 47 creating classes.Adoption requests relationship fields. The API answers
nullfor anything not asked for, so a bare lookup reporteddomains: nullon an entity that already had one, and the caller's ownadd /domains/0was then rejected withRULE_VIOLATION: Multiple Domains are not allowed.Domain assignment is idempotent.
op: 'add', path: '/domains/0'appends;path: '/domains'with an array sets. 56 sites converted.domainIsolationUtils.tsalready used this form.Bounded 404 retry.
createOrFetchretries a create whose dependency the server cannot see yet, andwithNotFoundRetrywraps all 41apiContext.patchsites in the support classes. A 404 means the request was rejected outright, so nothing was partially applied and re-sending is safe. Three attempts at 300/600/900ms; a genuinely wrong reference still fails, ~1.8s later.FQN quoting is structural, not per-call-site.
buildFqn(...segments)quotes each raw name and joins, andcreateOrFetchtakesfqnSegments: string[], so no call site knows the escaping rules and a future fixture name containing a separator cannot silently break the lookup.quoteFqnSegmentmirrorsFullyQualifiedName.quoteNameexactly — including escaping an embedded quote by doubling it, not backslashing it.Type of change:
High-level design:
Two helpers in
playwright/utils/apiResponse.tsthat every creating class routes through, rather than 141 one-off guards.okJsonis the failure boundary;createOrFetchis the 409 boundary;buildFqn/quoteFqnSegmentown FQN escaping.Scope was held deliberately: 25 classes stay on raw POST because their lookup is not a plain name-addressed create (
BundleTestSuitedeploy/trigger,Task,UserClass's/users/signup,Alert,KnowledgeCenter,LearningResource) or the FQN composition is intricate (the multi-child builders). None of them 409ed in the 113 traces, and a wrong FQN is worse than the status quo — it turns a recoverable 409 into a hard error. They are all still covered byokJson, so any future 409 there fails loudly with the collection and status named.Tests:
Use cases covered
Unit tests
Not applicable — Playwright harness code, not product code.
Backend integration tests
Ingestion integration tests
Playwright (UI) tests
No new specs. This changes shared fixture infrastructure used by the existing suite; the affected specs (
PlatformLineage,NotificationTemplate,TestSuite,LineageFilters) already exist and are the ones flaking.AUT (nightly topology) run
This change targets a failure mode that only appears when many Playwright processes share one
server, which PR CI cannot reproduce — every PR machine gets its own backend. It was therefore
validated on the nightly kind topology (8 shards x 3 workers against a single Collate backend),
run against both databases:
https://github.com/open-metadata/openmetadata-nightly/actions/runs/32354810496
Against the pre-change nightly profile of 19-37 flaky / 1-6 hard failures, and against the
first guarded run on this topology (4 failed / 21 flaky), hard failures are down to one on each
database — and that one is a known webhook-infrastructure issue tracked separately, unrelated to
this PR.
Every flake this change set out to fix is gone from both lanes:
PlatformLineage(10/13 on 2.0)NotificationTemplate(9/13 on 2.0, 10/12 on 1.13)TestSuite > Logical TestSuitePagination > RolesOne guard-attributable flake remains on each lane —
ApiServiceClass.patch failed (404), whichpasses on retry. It survives a 1.8s bounded retry, so the cause is most likely a concurrent
teardown hard-deleting the service (fixture isolation) rather than write visibility. Everything
else in the flaky lists is UI-timeout shaped with no API-layer involvement.
Latent bugs this surfaced.
okJsonmakes previously swallowed errors throw, so it exposespre-existing bugs as well as fixing them. Each was fixed in this branch:
Pagination's Roles fixture passedpolicy.responseData.idwherecreateRole.policiesis typedentityName, so the server resolved a UUID by name and 404ed — deterministically, on everyattempt. Every other
RolesClass.createcall site already passed.name.hasDomain('...')passed an argument to a no-arg rule function.SubDomainsent an unquoted dotted parent FQN.resourcesvalue the server rejects.Failures of that shape are newly visible, not newly broken.
Fixture hygiene. Seven
Paginationdescribe blocks seeded entities and never removed them —metrics, notification alerts, observability alerts, roles, policies, bots, and the tasks pipeline.
Every block that did clean up was deleting a parent service and relying on the cascade, so the
top-level types (which have no parent) leaked ~120 rows per run into the list endpoints other specs
read. All 21 blocks now tear down what they create.
Manual testing performed
Ran the modified support classes against a live 2.0.0-SNAPSHOT server — 7/7:
Separately confirmed the API semantics the change relies on (13/13): duplicate create → 409; name lookup resolves incl. nested
service.database; a bare lookup hides an assigned domain while?fields=domains,owners,tagsreveals it;/domains/0reproduces the 400 rule violation;/domains+ array succeeds and is idempotent; andquoteFqnSegment('has"quote')→"has""quote".Two bugs were found only by executing this —
Domain.createfailed outright on its dotted name, and the quote escaping was backslash rather than doubled. Neither was visible to any static check.Gates:
tsc -p playwright/tsconfig.jsonis 163 errors before and after (zero introduced, zero removed vsorigin/main); eslint 0 errors; the CI lint sequence is idempotent; everydelete()in the touched entity classes is byte-identical tomain.UI screen recording / screenshots:
Not applicable — no UI changes.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.Greptile Summary
The PR improves Playwright fixture reliability by validating API responses immediately and recovering from concurrent entity-creation conflicts.
Confidence Score: 5/5
The PR appears safe to merge because no blocking failure remains within the eligible follow-up review scope.
No blocking failure remains.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Create fixture] --> B{Response status} B -->|2xx| C[Parse validated JSON] B -->|404| D[Retry create briefly] D --> B B -->|409| E[Build and quote entity FQN] E --> F[Fetch existing entity with requested fields] F --> C B -->|Other failure| G[Throw status and response body] C --> H[Store usable fixture state]Reviews (10): Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." | Re-trigger Greptile