Skip to content

fix(app): handle 409 duplicate-name raised as a bare AtlanError#960

Merged
Aryamanz29 merged 1 commit into
mainfrom
fix/app-409-duplicate-name
Jun 26, 2026
Merged

fix(app): handle 409 duplicate-name raised as a bare AtlanError#960
Aryamanz29 merged 1 commit into
mainfrom
fix/app-409-duplicate-name

Conversation

@Aryamanz29

Copy link
Copy Markdown
Member

What

client.app.create(...) is meant to be idempotent on a duplicate name (create-or-reuse-by-name), but the reuse never triggered against the real server response.

The create endpoint's duplicate-name 409 body is {"message": "…already exists…", "slug": "…", "version": …} — it has no code/status field, so the transport (_call_api) falls through to its generic raise AtlanError(...) instead of the mapped ConflictError. create only caught ConflictError, so the 409 propagated raw and re-running a script errored.

(Followup to #959, which merged before this fix landed on the branch — 9.8.0 is unreleased, so no version bump.)

Fix

  • create (sync + async) now catches AtlanError and checks error_code.http_error_code == 409 (is_duplicate_name_conflict).
  • On a 409 it reads the existing slug straight from the response body (existing_slug_from_conflict) — no extra call — and falls back to a by-name get_all(name=...) lookup if the body lacks one. A non-unique name re-raises the conflict. Shared helpers live in pyatlan/client/common/app.py.

Tests

  • Replaced the unit test that fabricated a ConflictError (and thus missed this path) with one using the real error shape (bare AtlanError + JSON body); added a case asserting body-slug reuse needs no second call.
  • Verified live on a tenant: test_create_duplicate_name_reuses_existing and test_get_all_by_name_resolves_slug both pass.
  • ruff + mypy clean; 25/25 app-client unit tests pass.

🤖 Generated with Claude Code

@Aryamanz29 Aryamanz29 self-assigned this Jun 26, 2026
@Aryamanz29 Aryamanz29 added the bugfix Bug fix pull request label Jun 26, 2026
The create endpoint's 409 body has no code/status field, so the transport
raises a plain AtlanError (not the mapped ConflictError) — create() now catches
AtlanError + checks the 409 status, and reuses the existing slug straight from
the response body (falling back to a by-name lookup). Adds a unit test using the
real error shape (the prior test fabricated a ConflictError and missed this).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Aryamanz29 Aryamanz29 force-pushed the fix/app-409-duplicate-name branch from 9233632 to 9ff137c Compare June 26, 2026 13:43
@Aryamanz29 Aryamanz29 merged commit dbe5bff into main Jun 26, 2026
27 of 28 checks passed
@Aryamanz29 Aryamanz29 deleted the fix/app-409-duplicate-name branch June 26, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Bug fix pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant