Skip to content

Suppress Dremio Cloud 400 "already exists" in folder creation#318

Merged
99Lys merged 1 commit into
dremio:mainfrom
99Lys:DX-117811-cloud-folder-already-exists
May 15, 2026
Merged

Suppress Dremio Cloud 400 "already exists" in folder creation#318
99Lys merged 1 commit into
dremio:mainfrom
99Lys:DX-117811-cloud-folder-already-exists

Conversation

@99Lys
Copy link
Copy Markdown
Contributor

@99Lys 99Lys commented May 12, 2026

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

  • pytest tests/unit/ — 8/8 tests pass
  • tests/unit/test_rest_utils.py (new) — _check_error mapping:
    • 400 + "already exists" → DremioAlreadyExistsException
    • 400 + other message → DremioBadRequestException (regression guard) ✓
    • 409 → DremioAlreadyExistsException (regression guard) ✓
  • 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.
  • 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

🤖 Generated with Claude Code

@99Lys 99Lys changed the title DX-117811: Suppress Dremio Cloud 400 "already exists" in folder creation Suppress Dremio Cloud 400 "already exists" in folder creation May 12, 2026
@99Lys 99Lys marked this pull request as draft May 12, 2026 16:09
Dremio Cloud returns HTTP 400 with "An object already exists with that
name" when a folder already exists, whereas Software returns HTTP 409.
The Software case is already swallowed by the DremioAlreadyExistsException
branch in _create_folders, but the Cloud case fell into the
DremioBadRequestException branch and crashed dbt run.

Normalize at the API boundary: _check_error reroutes 400 + the
"already exists" message to DremioAlreadyExistsException. Existing
handlers in _create_folders and _create_space catch both cases
uniformly with no changes.

DX-117811 / dbt-dremio#313

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@99Lys 99Lys force-pushed the DX-117811-cloud-folder-already-exists branch from 5fe99b8 to ee81ba2 Compare May 13, 2026 10:21
@99Lys 99Lys marked this pull request as ready for review May 13, 2026 10:26
@99Lys 99Lys merged commit 5a6798a into dremio:main May 15, 2026
18 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants