Skip to content

fix(quota-tracker): narrow bare except to ImportError (closes #1062) - #1283

Closed
sonichi wants to merge 1 commit into
mainfrom
fix/quota-tracker-bare-except
Closed

sonichi wants to merge 1 commit into
mainfrom
fix/quota-tracker-bare-except

Conversation

@sonichi

@sonichi sonichi commented May 28, 2026

Copy link
Copy Markdown
Owner

Summary

Per Lucy's #1055 review (item 1): the bare except Exception: on read-quota.py:26 masked a path off-by-one for half a day — any unexpected error set _canonical = None and printed the misleading "not found" message instead of surfacing the real failure.

The only anticipated failure at this call site is ImportError (workspace_default not importable because sys.path is wrong). Narrowing to ImportError:

  • Lets AttributeError, TypeError, disk errors, and any other unexpected exceptions propagate to the caller
  • Makes silent fallback failures visible instead of swallowing them

Change

# Before
except Exception:
    _canonical = None

# After
except ImportError:
    _canonical = None

One line changed. No behavior change for the normal path or for missing-module installs.

Test plan

  • python3 skills/quota-tracker/scripts/read-quota.py on a machine with workspace_default importable → same output as before
  • On a machine where the import fails → same "not found" message (ImportError still caught)

🤖 Generated with Claude Code

Per Lucy's #1055 review: the bare `except Exception:` on line 26 masked the
path off-by-one for half a day. An `ImportError` is the only expected failure
here — `workspace_default` not importable (wrong sys.path). Narrowing to
`ImportError` lets unexpected exceptions (AttributeError, TypeError, disk
failure) surface to the caller instead of silently setting `_canonical = None`
and printing a misleading 'not found' message.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sonichi

sonichi commented May 28, 2026

Copy link
Copy Markdown
Owner Author

Closing as duplicate of #1094 (VasiliyRad opened this fix first; I missed it when opening #1283). #1094 is the canonical fix for #1062.

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