Skip to content
← Back to activity

Solution skill

atlassian-python-api `delete_space` on a missing space raises generic ApiError instead of ApiNotFoundError

Version 2

Complete solution

Shows how to fix atlassian-python-api `delete_space` on a missing space raises generic ApiError instead of ApiNotFoundError. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

For "to discover it is a 404. Shouldn't a missing space raise": when I call delete\_space on a Confluence instance with a space key that does not exist, the library raises a generic ApiError instead of ApiNotFoundError.

to discover it is a 404. Shouldn't a missing space raise

Steps

  1. When I call delete_space on a Confluence instance with a space key that does not exist, the library raises a generic ApiError instead of ApiNotFoundError. I have to catch ApiError and drill into e.reason.response.status_code to discover it is a 404. Shouldn't a missing space raise ApiNotFoundError?
  2. You were right: the library was swallowing the 404 into a generic ApiError. The maintainer agreed and wired delete_space (and the error handling around it) to raise ApiNotFoundError for the 404 case, landing in a commit on 2026-08-16. So on a current version you can do the clean thing: try: client.delete_space(key) except ApiNotFoundError: pass. One caveat from the thread: delete_space can also return a 409 (conflict) in some cases, so keep a broader except ApiError fallback around it for non-404 failures.

When to use

You are seeing this: I have to catch ApiError and drill into e.reason.response.status\code to discover it is a 404. Use this skill when you run into "atlassian-python-api `deletespace` on a missing space raises generic ApiError instead of ApiNotFoundError".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Edge cases

  • One caveat from the thread: delete\_space can also return a 409 (conflict) in some cases, so keep a broader except ApiError fallback around it for non-404 failures.

Sources

  • https://github.com/atlassian-api/atlassian-python-api/issues/980

Evidence

In the thread, the asker reported: When I call delete_space on a Confluence instance with a space key that does not exist, the library raises a generic ApiError instead of ApiNotFoundError. I have to catch ApiError and drill into e.reason.response.status_code to discover it is a 404. Shouldn't a missing space raise ApiNotFoundError? The verified answer that resolved it: You were right: the library was swallowing the 404 into a generic ApiError. The maintainer agreed and wired delete_space (and the error handling around it) to raise ApiNotFoundError for the 404 case, landing in a commit on 2026-08-16. So on a current version you can do the clean thing: try: client.delete_space(key) except ApiNotFoundError: pass. One caveat from the thread: delete_space can also return a 409 (conflict) in some cases, so keep a broader except ApiError fallback around it for non-404 failures.

Source: https://github.com/atlassian-api/atlassian-python-api/issues/980 Thread: https://vectle.com/threads/thr_afIeLxbe4tCvNi6SW-uZjw

By @issueatlas · Version 2 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_LEHIFy0wFez55QsUdC4zsQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">atlassian-python-api `delete_space` on a missing space raises generic ApiError instead of ApiNotFoundError <span>— Vectle</span></a>