Commit 8e99b40
committed
sea-auth-u2m: address round-1 review (HIGH error-mapping wiring + 7 mediums)
Ports the M2M-side devils-advocate round-1 fixes (commit eef9d30 on
sea-auth-m2m) onto the U2M worktree. Same shape, with the U2M-specific
adjustments noted below.
## DA-F1 (HIGH) — kernel-error envelope decoding wired into SeaBackend
Added `decodeNapiKernelError(err: unknown): Error` to
`SeaErrorMapping.ts` and wrapped `SeaBackend.openSession`'s napi call
in `try`/`catch` + the decoder. The wiring step was missing on both
branches; now M2M and U2M users see typed errors
(`AuthenticationError` on Unauthenticated, `HiveDriverError` on
NetworkError, etc.) instead of raw `Error` with sentinel-prefixed
message bodies.
## DA-F2 (medium) — ambiguous-creds rejection
`buildSeaConnectionOptions` rejects:
- PAT path + stray OAuth fields → HiveDriverError "cannot supply
both `token` and `oauthClientId`/`...Secret`".
- OAuth path (M2M or U2M) + stray `token` → HiveDriverError
"cannot supply `token` alongside `authType: 'databricks-oauth'`".
The OAuth-side check fires BEFORE the M2M/U2M split, so the U2M
arm gets the protection too.
## DA-F3 (medium) — durable error messages, no milestone names
Rewrote three M2M-arm error messages plus the U2M persistence
message to be time-bound free:
- "U2M lands in sea-auth-u2m" → "OAuth M2M requires
`oauthClientSecret`. For interactive OAuth (U2M), see the driver
OAuth U2M docs."
- "Azure-direct OAuth ... is a later M1 task" → "Azure-direct OAuth
... is not supported. The workspace-OIDC discovery path handles
Azure workspaces today without these options."
- "M1+ follow-ups" → "Supported modes on the SEA backend today: ..."
- U2M persistence: dropped "M1 Phase 2" — kept the technical
explanation citing kernel-side `AuthConfig::External` plumbing
(durable; describes the kernel gap, not the feature roadmap).
Zero hits for `sea-auth-u2m|sea-auth-m2m|later M1|M1\+ follow|M1 Phase`
in `lib/sea/`. Updated regex assertions in lockstep.
## DA-F4 (medium) — input sanitization
`isBlankOrReserved(s)` helper trims + rejects empty-after-trim and
literal `'undefined'` / `'null'` strings. Applied to `token`,
`oauthClientId`, `oauthClientSecret`. E2e env-gate hardened the
same way.
## DA-F5 (medium) — missing unit cases
Added `tests/unit/sea/auth-edge-cases.test.ts` with 18 cases:
- Whitespace + reserved-literal PAT (3)
- Same for `oauthClientId` / `oauthClientSecret` on M2M (4)
- Ambiguous-creds: PAT+id, PAT+secret, M2M+token, U2M+token (4)
- Explicit-undefined Azure-direct discriminants on M2M + U2M (3)
- `decodeNapiKernelError` for Unauthenticated, NetworkError,
SQLSTATE preservation, plain napi pass-through, corrupted
envelope fallback (5)
## DA-F6 (medium) — negative-path e2e
Added a bad-secret `it(...)` block to `auth-m2m-e2e.test.ts` that
asserts `AuthenticationError` + `invalid_client`. Closes the loop on
DA-F1 by proving the kernel-side error path surfaces correctly.
The U2M e2e remains `it.skip` pending the Playwright/Puppeteer harness;
once it lands, the same negative-path pattern can be added there.
## Items not addressed (same as M2M-worktree commit)
L-F3, L-F4, L-F5 — deferred per the previous fixup's reasoning.
Tests:
- Unit: 74/74 pass (was 55 before this commit: +18 from edge-cases
+ 1 from new pending placeholder count).
- TypeScript build: clean.
- Native build: unchanged (no Rust changes this commit).
Co-authored-by: Isaac1 parent 4f6ccc0 commit 8e99b40
7 files changed
Lines changed: 520 additions & 39 deletions
File tree
- lib/sea
- tests
- integration/sea
- unit/sea
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
80 | 93 | | |
81 | 94 | | |
82 | 95 | | |
| |||
87 | 100 | | |
88 | 101 | | |
89 | 102 | | |
90 | | - | |
91 | | - | |
92 | | - | |
| 103 | + | |
93 | 104 | | |
94 | 105 | | |
95 | 106 | | |
| |||
99 | 110 | | |
100 | 111 | | |
101 | 112 | | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
111 | 126 | | |
112 | 127 | | |
113 | | - | |
| 128 | + | |
114 | 129 | | |
115 | | - | |
| 130 | + | |
116 | 131 | | |
117 | 132 | | |
118 | 133 | | |
| |||
122 | 137 | | |
123 | 138 | | |
124 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
125 | 148 | | |
126 | 149 | | |
127 | | - | |
| 150 | + | |
128 | 151 | | |
129 | 152 | | |
130 | 153 | | |
131 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
132 | 162 | | |
133 | 163 | | |
134 | 164 | | |
135 | 165 | | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
143 | 172 | | |
144 | 173 | | |
145 | 174 | | |
146 | 175 | | |
147 | | - | |
148 | | - | |
| 176 | + | |
| 177 | + | |
149 | 178 | | |
150 | 179 | | |
151 | 180 | | |
| |||
156 | 185 | | |
157 | 186 | | |
158 | 187 | | |
159 | | - | |
| 188 | + | |
160 | 189 | | |
161 | 190 | | |
162 | 191 | | |
| |||
171 | 200 | | |
172 | 201 | | |
173 | 202 | | |
174 | | - | |
175 | | - | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
176 | 207 | | |
177 | | - | |
| 208 | + | |
178 | 209 | | |
179 | | - | |
| 210 | + | |
180 | 211 | | |
181 | 212 | | |
182 | 213 | | |
| |||
195 | 226 | | |
196 | 227 | | |
197 | 228 | | |
198 | | - | |
199 | | - | |
| 229 | + | |
| 230 | + | |
200 | 231 | | |
201 | 232 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
158 | 159 | | |
159 | 160 | | |
160 | 161 | | |
161 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
162 | 168 | | |
163 | 169 | | |
164 | 170 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
6 | 15 | | |
7 | 16 | | |
8 | 17 | | |
| |||
139 | 148 | | |
140 | 149 | | |
141 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
52 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
53 | 64 | | |
54 | 65 | | |
55 | 66 | | |
| |||
77 | 88 | | |
78 | 89 | | |
79 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
80 | 119 | | |
0 commit comments