Commit 5a6798a
Suppress Dremio Cloud 400 "already exists" in folder creation (#318)
## Summary
Dremio Cloud returns HTTP 400 with `"An object already exists with that
name"` when a folder already exists during `_create_folders`, whereas
Dremio Software returns HTTP 409. The Software 409 case is already
swallowed by the existing `DremioAlreadyExistsException` handler in
`_create_folders`, but the Cloud 400 case fell into the
`DremioBadRequestException` branch and crashed `dbt run`.
This PR normalizes at the API boundary: `_check_error` in
`dbt/adapters/dremio/api/rest/utils.py` now reroutes 400 + `"An object
already exists with that name"` to `DremioAlreadyExistsException`. The
existing handlers in `_create_folders` and `_create_space` catch both
Cloud and Software cases uniformly with no changes.
### Why at this layer
- Centralizes the Cloud-vs-Software server quirk at the API boundary.
- Future callers of any catalog API automatically benefit.
- Exception type matches its semantic meaning (already-exists,
regardless of HTTP status code).
- `connections.py` stays unchanged — no scope creep.
## Test Plan
- [x] `pytest tests/unit/` — 8/8 tests pass
- [x] `tests/unit/test_rest_utils.py` (new) — `_check_error` mapping:
- 400 + "already exists" → `DremioAlreadyExistsException` ✓
- 400 + other message → `DremioBadRequestException` (regression guard) ✓
- 409 → `DremioAlreadyExistsException` (regression guard) ✓
- [x]
`tests/unit/test_connection.py::TestCreateFolders::test_create_folders_swallows_already_exists`
(new) — end-to-end: `_create_folders` swallows the rerouted exception,
loop continues, method returns normally.
- [x] `black` + `flake8` clean on touched files.
## Risk
The match string `"An object already exists with that name"` is a
literal substring against the response body. If Cloud ever changes the
wording, the fallback path raises `DremioBadRequestException` and `dbt
run` crashes (current baseline). Acceptable trade-off; we can add
another substring if needed.
## References
- Original bug report: #313
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent eac8389 commit 5a6798a
3 files changed
Lines changed: 92 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
123 | 130 | | |
124 | 131 | | |
125 | 132 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
| |||
46 | 49 | | |
47 | 50 | | |
48 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
0 commit comments