Skip to content

fix(assets): find public catalog assets by registry id when a workspace is configured - #43

Open
rishabh-bansal wants to merge 1 commit into
cyberwave-os:mainfrom
rishabh-bansal:fix/registry-lookup-with-workspace
Open

rishabh-bansal wants to merge 1 commit into
cyberwave-os:mainfrom
rishabh-bansal:fix/registry-lookup-with-workspace

Conversation

@rishabh-bansal

Copy link
Copy Markdown

What changed and why?

With a workspace configured, public catalog assets can't be found by registry id, so cw.twin("dji/tello") fails with CyberwaveError: Asset 'dji/tello' not found.

Cause: the client appends the configured workspace (CYBERWAVE_WORKSPACE_ID, or the one get_or_create_quickstart_environment() saves on config.workspace_id) to every request as workspace_uuid (_with_workspace_query_param). On GET /api/v1/assets that limits results to the workspace's own assets, so the public catalog disappears. public_only=true doesn't help, because the workspace filter still applies.

Measured against the live API (cyberwave 0.7.5, single-workspace token):

Client state get_by_registry_id("dji/tello")
fresh client found
config.environment_id set only found
config.workspace_id set (directly or via quickstart) None
workspace set + explicit workspace_uuid= (empty) on the call found

This hits the common path: cw.twin("vendor/model") without an environment_id calls get_or_create_quickstart_environment() (which saves the workspace) and then looks up the asset. It also hits anyone who sets CYBERWAVE_WORKSPACE_ID, which the README asks for with multi-workspace tokens.

Fix: get_by_registry_id keeps the workspace-scoped lookup first, so workspace assets still win. If that finds nothing, it retries the same ?registry_id= lookup catalog-wide by passing an explicit empty workspace_uuid. _with_workspace_query_param already leaves an explicit workspace_uuid alone. No public signature changes; list_by_registry_id is untouched.

I haven't been able to test a multi-workspace token. If the backend answers an empty workspace_uuid with 400 workspace_required there, the new step fails inside the existing try/except and the method behaves as before. If you'd rather fix this server-side, or by not attaching the ambient workspace to catalog reads, I'm happy to rework it.

How did you test it?

  • New tests/test_registry_lookup_workspace.py (4 tests): the catalog-wide call sends workspace_uuid=""; an explicit empty workspace isn't overwritten by the configured one; get_by_registry_id falls back when the scoped lookup is empty; a workspace asset still wins without the fallback being called. 3 of them fail on main.
  • pytest tests/test_registry_lookup_workspace.py tests/test_asset_aliases.py tests/test_slug_support.py tests/test_client_twin.py → 48 passed.
  • Live: with a workspace configured via get_or_create_quickstart_environment(), get_by_registry_id("dji/tello") now returns the asset (it returned None before).
  • mypy cyberwave/resources.py: the same 17 pre-existing errors before and after.

Contributor checklist

  • I added or updated tests for behavior changes, or explained why they are unnecessary.
  • I updated relevant documentation or examples. (n/a)
  • I noted any public API, optional dependency, or simulation/live behavior changes. (no API change; one extra request only when the scoped lookup misses)

Recognition

  • Please skip the Discord celebration for this PR.

🤖 Generated with Claude Code

…ce is configured

With a workspace configured (CYBERWAVE_WORKSPACE_ID, or the one
get_or_create_quickstart_environment saves), every request carries workspace_uuid,
which on /api/v1/assets limits results to that workspace's own assets. So
cw.twin("dji/tello") failed with "Asset 'dji/tello' not found".

get_by_registry_id now retries a catalog-wide lookup (explicit empty workspace_uuid,
which the client leaves alone) when the workspace-scoped one finds nothing.
Workspace assets still win.

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

Copy link
Copy Markdown

Thanks for contributing to the Cyberwave Python SDK, @rishabh-bansal!

Maintainer contacts: @KhushiSharma22. When this PR is ready, we request a maintainer review and run an automated advisory review. CI and human review remain the source of truth.

Please describe what changed and how you tested it. See the contribution guide or ask for help on Discord. Drafts are welcome.

Merged human contributions receive a Discord thank-you. To opt out, check the PR template's Discord opt-out box or add <!-- cyberwave:no-celebration --> to the PR description.

@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Slack team notifications

  • opened: sent

@github-actions

Copy link
Copy Markdown

Automated advisory review · Claude

Commit: 4de7affd5cf3c2bf9d0113e0a35f845acdfcd8d3. Human review and CI are still required.

The patch adds a catalog-wide fallback lookup for public assets by passing an explicit empty `workspace_uuid` query parameter. The logic and tests are mostly sound, but there is one concrete defect: the bare `except Exception: pass` guard around the new catalog-wide lookup silently swallows all failures, including the case where the call succeeds and returns results but processing them raises (e.g. a malformed response). More critically, the same broad suppression already existed on the workspace-scoped call, and the new fallback extends that pattern so a network or deserialization error in `_list_by_registry_id_catalog_wide` is indistinguishable from 'no results', causing `get_by_registry_id` to silently continue to the slower keyword-search fallback rather than surfacing the error. This is a medium-severity behavioral defect introduced by the patch. No other high-confidence defects are evident from the supplied excerpts.

  • Medium · cyberwave/resources.py: The new catalog-wide fallback in `get_by_registry_id` is wrapped in a bare `except Exception: pass` block (matching the pre-existing pattern for the workspace-scoped call). If `_list_by_registry_id_catalog_wide` raises due to a transient network error, an authentication failure, or a deserialization problem, the exception is silently discarded and execution falls through to the last-resort keyword search. This means: (1) a real error that should surface to the caller is hidden, (2) the slower keyword search runs unnecessarily, and (3) if the keyword search also fails silently, `get_by_registry_id` returns `None` with no diagnostic information. The fix is to catch only the specific exception type(s) that indicate 'not found' or 'empty result' (e.g. the generated client's ApiException with a 404 status), and let unexpected exceptions propagate. At minimum, log the exception at DEBUG level before suppressing it so operators can diagnose failures.

Coverage: 2 of 2 changed files; patch excerpts only. Generated REST code, lockfiles, notebooks, SVGs, missing patches and files beyond the 40-file / 60,000-character budget are excluded. GitHub may truncate individual patches.

This branch has not been deployed

No deployments
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.

1 participant