Commit 06b4272
authored
apierr: Alias ErrResourceAlreadyExists to ErrAlreadyExists (#1639)
## Changes
`apierr` defined two 409 sentinels with identical messages but distinct
pointers:
- `ErrAlreadyExists` — mapped from `error_code: ALREADY_EXISTS`
(gRPC canonical)
- `ErrResourceAlreadyExists` — mapped from `error_code:
RESOURCE_ALREADY_EXISTS` (Databricks-specific)
Consumers using `errors.Is` with one sentinel did not match errors
wrapped with the other, even though both represent the same class of 409
conflict. Which of the two `error_code` strings the backend returns is
not guaranteed, so consumers had to either assert the generic
`ErrResourceConflict` or duplicate both sentinels in their checks.
This came up downstream in databricks/cli#5043
where a `TestDashboardAssumptions_WorkspaceImport` assertion on
`ErrResourceAlreadyExists` started failing because the Lakeview API
returns `ALREADY_EXISTS` rather than `RESOURCE_ALREADY_EXISTS`.
Alias `ErrResourceAlreadyExists` to `ErrAlreadyExists` so `errors.Is`
matches either `error_code` regardless of which the backend emits. The
exported symbol is preserved, so this is source- and binary-compatible
for all existing callers.
Also extended `TestErrorMapping` to cover both error_codes against both
sentinels and against the shared `ErrResourceConflict` parent.
## Tests
- [x] `go test ./apierr/...` passes, including new
`RESOURCE_ALREADY_EXISTS` ↔ `ErrAlreadyExists` and `ALREADY_EXISTS` ↔
`ErrResourceAlreadyExists` cases.
- [x] `make fmt` clean.
- [x] `make lint` clean.
Signed-off-by: simon <simon.faltum@databricks.com>1 parent 7aae318 commit 06b4272
3 files changed
Lines changed: 15 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
21 | 25 | | |
22 | 26 | | |
23 | 27 | | |
| |||
0 commit comments