Skip to content

Handle unwritable Base cache roots without Python tracebacks #895

@codeforester

Description

@codeforester

Problem

Python-based Base commands can crash with a Python traceback during context creation when the Base cache/log root is not writable.

Evidence:

  • lib/python/base_cli/app.py:146-162 creates logs, cache, and tmp directories before configuring the logger.
  • lib/python/base_cli/app.py:188-200 catches Click exceptions, but not OSError from context creation.

Reproduction:

tmpdir=/private/tmp/base-unwritable-cache-review
mkdir -p "$tmpdir"
chmod 500 "$tmpdir"
BASE_CACHE_DIR="$tmpdir" basectl workspace status --workspace /tmp --format json
chmod 700 "$tmpdir"

Observed behavior:

  • The command exits with a Python traceback ending in PermissionError: [Errno 13] Permission denied.
  • The failure happens before command-specific handling can explain the cache root or suggest BASE_CACHE_DIR.

This can happen outside tests if a cache directory is root-owned, stale from a previous install path, on a locked-down workstation, or pointed at an unwritable location.

Desired outcome

Base should fail with a concise diagnostic when its runtime cache/log directories cannot be created.

Acceptance criteria

  • Context creation catches cache/log/temp directory OSError failures and returns a user-facing error without traceback.
  • The message names the failing path and mentions BASE_CACHE_DIR when the default cache root is unusable.
  • Dry-run and explicit --log-file behavior continue to respect their no-default-cache-write contract.
  • Tests cover an unwritable BASE_CACHE_DIR or equivalent injected cache root.

Metadata

Metadata

Assignees

Labels

bugSomething is not working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions