fix(app): handle 409 duplicate-name raised as a bare AtlanError#960
Merged
Conversation
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>
9233632 to
9ff137c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
409body is{"message": "…already exists…", "slug": "…", "version": …}— it has nocode/statusfield, so the transport (_call_api) falls through to its genericraise AtlanError(...)instead of the mappedConflictError.createonly caughtConflictError, so the409propagated 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 catchesAtlanErrorand checkserror_code.http_error_code == 409(is_duplicate_name_conflict).409it reads the existing slug straight from the response body (existing_slug_from_conflict) — no extra call — and falls back to a by-nameget_all(name=...)lookup if the body lacks one. A non-unique name re-raises the conflict. Shared helpers live inpyatlan/client/common/app.py.Tests
ConflictError(and thus missed this path) with one using the real error shape (bareAtlanError+ JSON body); added a case asserting body-slug reuse needs no second call.test_create_duplicate_name_reuses_existingandtest_get_all_by_name_resolves_slugboth pass.ruff+mypyclean; 25/25 app-client unit tests pass.🤖 Generated with Claude Code