Catalog: honor a mis-cased Athena workgroup and stop masking the bucket default (5217 stack 7/9) - #5265
Conversation
fc62d13 to
d0a70fc
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## stack/5217-6-admin-service-read-only #5265 +/- ##
========================================================================
+ Coverage 35.99% 36.01% +0.01%
========================================================================
Files 741 741
Lines 23829 23836 +7
Branches 6434 6438 +4
========================================================================
+ Hits 8577 8584 +7
Misses 13520 13520
Partials 1732 1732
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
d0a70fc to
69feefe
Compare
69feefe to
0d90f52
Compare
0d90f52 to
5fdfde0
Compare
5fdfde0 to
f70e322
Compare
523db3f to
bbead11
Compare
bbead11 to
9c96dcb
Compare
Local code review — findings and dispositionsReviewed this layer only ( Accepted1. An exact workgroup match had to beat a case-insensitive one — regression in this layer. 2. A non-string 3. The changelog entry claimed more than this layer ships. It announced Declined4. 5. The preference document can resolve after the workgroup is seeded. Declined here: real, but #5267 gates the scoped mount on the resolved document, which is the right layer for it. 6. Also sweptComments were retelling what the change did and what the old code got wrong — the tests already pin that. Trimmed to what the code cannot show: why the canonical spelling must be used, why the preference crosses as a string rather than the Test hygiene: the stubbed-mock restores now sit in a Verification80 tests pass in the two touched spec files (2 new, each confirmed failing without its fix); |
…ces object `Model.Provider` takes an optional `preferences` prop and hands `ui.athena .defaultWorkgroup` to `useWorkgroup`, which now takes that one string instead of the whole `AthenaPreferences` object. The parsed preferences are rebuilt on every provider render, so an object here would re-fire the workgroup effect throughout the probe. A no-op on its own: nothing passes the new prop yet, so behavior is identical to before. It also takes `utils/BucketPreferences` out of the AWS-call layer entirely. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ault addresses review findings f34, f16, f33 Two bugs in one expression, both reachable through the default this branch restores. **f34 — the console errors instead of honoring the default.** The workgroup was matched case-insensitively and then stored and used verbatim. An admin writing `ui.athena.defaultWorkgroup: Analytics-Prod` against a workgroup named `analytics-prod` matched here, and then `listNamedQueries` and `startQueryExecution` sent the admin's casing and AWS rejected it with `InvalidRequestException`. Same hole for a mis-cased `:workgroup` URL segment. Candidates now resolve to the list's own spelling before being stored. **f16 — an unavailable stored workgroup masked a valid default.** With `storage.getWorkgroup() || defaultWorkgroup`, a stored workgroup that had been deleted or lost access was picked by the `||`, failed the availability check, and dropped through to the first workgroup in the list — never trying a bucket default that was perfectly valid. The candidates are tried in turn instead. Storage still outranks the bucket default; that ordering is not changed here (see f33 in the PR body). It is now pinned by a test in whichever direction it is set, which nothing did before. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
addresses review finding f46 The seam this branch exists to restore — `Model.Provider` taking `ui.athena` from the `?bucket=` scope and handing the default workgroup down — was crossed by no test. The prop could have been dropped on the floor and everything else here would still have passed. Drives it through the provider with a URL naming a workgroup the user cannot reach, which is also the only shape in which the default is observable: with no workgroup in the URL the provider redirects rather than rendering its children. The list's first entry is deliberately not the default, so the assertion cannot pass by the fallback happening to agree. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
addresses review findings f44, f27 The plan for this split had no changelog line here, on the grounds that the seam is a no-op. The two bug fixes folded in are not: a mis-cased workgroup erroring and a stale stored workgroup masking the bucket default are both user-visible, so they get an entry. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…g default Case-insensitive resolution alone picks whichever of 'Alpha' and 'alpha' sorts first, so an exactly-spelled request could land on the other workgroup. And ui.athena is unconstrained by the bucket-config schema, so an all-digit workgroup name arrives from YAML as a number and threw out of the effect.
The comments retold what the change did and what the old code got wrong; the tests already pin that. Keep only what the code cannot show: why the canonical spelling has to be used, why the preference crosses as a string, and that storage-before-default is inherited product behaviour. Restore the stubbed mocks in a finally: afterEach only clears call data, so a failing assertion leaked the stub into every later test in the file. The changelog entry now claims only what this layer ships on its own -- the bucket default it also mentioned is not wired until #5267, which announces it.
125ac21 to
5a2b996
Compare
Description
Two bugs in how the Athena console chooses a workgroup, plus the seam that lets a
bucket's
ui.athena.defaultWorkgroupreach that choice at all.The console errors instead of honoring the default. The workgroup was matched
case-insensitively and then stored and used verbatim. An admin writing
ui.athena.defaultWorkgroup: Analytics-Prodagainst a workgroup namedanalytics-prodmatched here — and thenlistNamedQueriesandstartQueryExecutionsent the admin's casing, and AWS rejected it withInvalidRequestException. The same hole swallowed a mis-cased:workgroupURLsegment. Candidates now resolve to the list's own spelling before being stored.
An unavailable stored workgroup masked a valid default. With
storage.getWorkgroup() || defaultWorkgroup, a stored workgroup that had beendeleted or lost access was picked by the
||, failed the availability check, anddropped through to the alphabetically-first workgroup — never trying a bucket
default that was perfectly good. Candidates are tried in turn instead.
The seam.
Model.Providertakes an optionalpreferencesprop and handsui.athena.defaultWorkgrouptouseWorkgroupas a string rather than the wholeobject — the parsed preferences are rebuilt on every provider render, so an object
would re-fire the workgroup effect throughout the probe.
Safe on its own. Nothing passes the new prop yet, so the seam is a no-op in
isolation and this PR stands as a refactor plus two real bug fixes. The consumer
that supplies the prop is PR 9.
Review findings addressed
still outranks the bucket default; only the fall-through changed.
Provider→useWorkgroupseam was crossed by no test, so theprop could have been dropped on the floor unnoticed. Now driven through the
provider.
direction. It is pinned now.
narrowing the third parameter to
defaultWorkgroup?: stringremovesutils/BucketPreferencesfrom the AWS-call layer entirely.storage.getWorkgroup()still outranksui.athena.defaultWorkgroup. That meansany user who has ever switched workgroup never sees the bucket default — which
is narrower than "honors that bucket's
defaultWorkgroupagain" implies.This precedence is not new: it exists verbatim in the 26.7.4 pin
(
eda3016f,Bucket/Queries/Athena/model/requests.ts:127), which is the baseline thehardening review compared master
(
6167dd82) against.Reordering it changes behaviour for returning users, which is a product decision
rather than hardening — so it is not silently reordered here.
A maintainer should rule on one of two things: either the precedence is
reordered deliberately in its own change, or the changelog wording narrows to
match what the code does. The test added here pins the current order, so a
deliberate reversal will show up as a test to change rather than a silent drift.
f16's fall-through fix is independent of this and lands either way.
Recorded, not fixed here
preferences?.defaultWorkgroupflattens a preference object to aprimitive at the consumer to dodge an unmemoized shared provider. Real; the
proper fix is to memoize
BucketPreferences, which is wider than this branch.(
listIncludesat five other call sites in this file). Untouched here: f34 namedthe workgroup, and those paths have their own storage-restore behaviour that
deserves its own reading rather than a blanket change.
Verification
102 tests. The four new ones in
requests.spec.tsand the one instate.spec.tsxwere each checked against the pre-fix code and fail there.
Position in the stack
PR 7 of 9, based on
stack/5217-6-admin-service-read-only.Part of the split of #5217 asked for in
f27. This
is the one hard mechanical dependency in that set, and the reason the Athena work
splits in two: the seam is a no-op in isolation, so it can land on its own merits
while the mount change that activates it (PR 9) waits on a direction call. Do
not squash this into PR 9 — that destroys the property that makes it
independently mergeable.
TODO
🤖 Generated with Claude Code
Greptile Summary
This PR corrects Athena workgroup selection by canonicalizing case-insensitive matches to AWS-provided names and trying stored and bucket-default candidates independently. It also adds an optional provider seam for forwarding the bucket’s default workgroup and expands focused test coverage.
preferences.defaultWorkgroupthrough the Athena model provider.Confidence Score: 5/5
The PR appears safe to merge, with the changed selection paths constrained to available Athena workgroups and covered by targeted regression tests.
The implementation resolves candidate names against Athena’s returned list, preserves the documented precedence, falls through unavailable candidates correctly, and introduces no active incompatibility because the new provider prop is optional.
Important Files Changed
Reviews (1): Last reviewed commit: "docs(changelog): entry for the workgroup..." | Re-trigger Greptile