Skip to content

Raise ProjectNotFoundError when a project doesn't exist (#302) - #555

Closed
tonylampada wants to merge 3 commits into
mainfrom
bc/SLM-103
Closed

tonylampada wants to merge 3 commits into
mainfrom
bc/SLM-103

Conversation

@tonylampada

@tonylampada tonylampada commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Fixes #302.

A typo'd or deleted project id in workspace.project() (#302) leaves the user with an error that is just the API's raw JSON, so nobody can tell which project failed or why. A 404 now raises ProjectNotFoundError, which names the workspace and project id and points to Trash and API-key access as the likely causes. Serves O8 (one canonical API shape on every surface): SDK, CLI and API now report a missing project the same way.

  • rfapi.get_project: 404 → ProjectNotFoundError(RoboflowError, RuntimeError); other statuses unchanged.
  • Roboflow.project() now uses the same adapter. It still raises RuntimeError, so existing except clauses keep working.
  • The CLI commands that look up a project (project get, infer, version, model, video) get the clearer message for free. They still exit with code 3.
  • The red ICN001 CI predates this PR (unpinned ruff 0.17); one unrelated commit aliases datetime as dt to unblock it.
  • The backend returns the same 404 for missing, trashed (deletedAt) and no-access projects, so the message lists all three.

Type of change

  • Bug fix (non-breaking)

How has this change been tested?

Any specific deployment considerations

None. This ships in the next SDK release.

Next step

Standalone fix. Next for O8: give CLI/SDK errors for other 404 lookups (versions, workspaces) the same treatment.

PLAN
touches   SDK project load (rfapi.get_project) → Workspace.project(), Roboflow.project(), CLI project lookups: 404 → ProjectNotFoundError naming ws+project (still RoboflowError; CLI catch blocks unchanged)
touches   Roboflow.project() → was RuntimeError(raw json); new error subclasses RuntimeError
touches   upload → unchanged; bad project id now fails at project(), before any upload
tests     project() 404 raises w/ ws+id · tests/test_project_not_found.py
tests     rf.project("ws/x") 404 same, still RuntimeError · same file
tests     non-404 errors unchanged · same file
review    actionable errors — says what failed + what to check
review    backwards compat — exception hierarchy preserved
verify    python -m unittest → all green; pre-commit + mypy clean

🤖 Generated with Claude Code

workspace.project("typo") raised a RoboflowError carrying the raw API JSON,
which names neither the workspace nor the project and doesn't say that a
trashed project answers the same 404 as a missing one. Map 404 from
GET /:workspace/:project to ProjectNotFoundError, which names both and lists
the three causes. Roboflow.project() now goes through the same adapter; the
new error also subclasses RuntimeError so existing except clauses still hold.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tonylampada

tonylampada commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator Author

Deliver checks (dm-brain playbooks/deliver):

  • Own review + verify recipe: new tests red on main, green here; full suite 1233 OK; pre-commit + mypy clean
  • Evidence gist: https://gist.github.com/tonylampada/062711136aec84e6214a5bf2f14b349a
  • PR description per contract (why/objective O8, what, tested, deploy, next, plan block)
  • Review round: lieutenant ruled no bot on this repo; one jarbas-review round, findings fixed or answered in the comment above
  • Not run against staging: no staging key available (per brief).

tonylampada and others added 2 commits October 13, 2026 22:19
CI installs ruff unpinned; 0.17 flags these two imports, unrelated to #302.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ent raises

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tonylampada

Copy link
Copy Markdown
Collaborator Author

Review round (jarbas-review, local branch scope, one round):

  1. ⚠️ test_missing_project_never_reaches_upload was tautological (.upload is never reached once project() raises) → fixed, removed (07041e5).
  2. 🤨 404 also covers a wrong or inaccessible workspace slug, but the message only blamed the project → fixed, message now names the workspace slug too.
  3. 🤨 Workspace.project / Roboflow.project docstrings didn't document the raise → fixed.
  4. 🤨 Roboflow.project('ws/proj/extra') quietly drops the extra part → won't fix, out of scope: predates this PR, not Python API upload fails silently if targeted project does not exist but was before #302.
  5. 🤨 Unrelated ICN001 commit → won't fix, out of scope: the red CI predates this PR (CI installs ruff unpinned; 0.17 flags two untouched files). The alias commit only unblocks CI and can be dropped if main fixes it first.

@tonylampada

Copy link
Copy Markdown
Collaborator Author

Night-loop drill run; closed by Selma.

@tonylampada
tonylampada deleted the bc/SLM-103 branch October 14, 2026 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python API upload fails silently if targeted project does not exist but was before

1 participant