Skip to content

internal/cli tests still follow Zero's per-file overrides, such as ZERO_OAUTH_TOKENS_PATH, into the developer's own files #1253

Backlog

Description

@Vasanthdev2004

What happens

#1250 makes internal/cli tests start from a throwaway home and removes the variables that outrank the home directories for whole directories (XDG_*, ZERO_SANDBOX_GRANTS_PATH, ZERO_WINDOWS_SANDBOX_HOME). Zero also has overrides for single files and stores, and those are left alone. When one is exported in the developer's shell, the tests that do not call their own helper still resolve that path to the developer's file:

variable read in
ZERO_OAUTH_TOKENS_PATH internal/oauth/store.go
ZERO_OAUTH_STORAGE internal/oauth/store.go, internal/cli/auth.go
ZERO_OAUTH_KEYRING_LOCK_PATH internal/oauth/store.go
ZERO_MCP_PERMISSIONS_PATH internal/mcp/permissions.go
ZERO_MCP_OAUTH_TOKENS_PATH internal/mcp/oauth_store.go
ZERO_SKILLS_DIR internal/skills/skills.go
ZERO_MODELS_CACHE_PATH internal/modelregistry/modelsdev.go
ZERO_DAEMON_REMOTE_TOKEN_FILE internal/daemon/remote/auth.go
XDG_RUNTIME_DIR internal/daemon/paths.go, internal/peermsg/service.go

XDG_RUNTIME_DIR is set in every systemd login session on Linux, so that one needs no unusual setup.

Reproduction

On Windows, with the test binary built from #1250, I pointed ZERO_OAUTH_TOKENS_PATH, ZERO_MCP_PERMISSIONS_PATH, ZERO_MCP_OAUTH_TOKENS_PATH, ZERO_SKILLS_DIR and ZERO_MODELS_CACHE_PATH into an empty decoy directory, seeded with an empty token store, an empty permissions file and one skill, and ran the whole package with -test.testlogfile:

  • the package passes;
  • the test log records 218 opens of the OAuth tokens file, 191 of the MCP permissions file, 89 of the MCP OAuth tokens path, and 167 of the decoy skill's SKILL.md;
  • the models cache path now holds a 6.7 MB modelsdev.json, plus a second copy named modelsdev-<digits>.json that was left beside it.

Nothing failed, so nothing in the run says it touched those files. With a real token store or a real skill in place, the tests read the developer's own. The ZERO_OAUTH_STORAGE=keyring case would send the same store loads to the OS keyring on macOS and Linux; I could not run either here, so that part is from reading the code.

Some helpers in the package already guard against these: withAuthStore in auth_test.go pins the file backend so an inherited ZERO_OAUTH_STORAGE=keyring cannot reach the keychain, isolateCLIUserState sets ZERO_MODELS_CACHE_PATH, and the daemon tests set XDG_RUNTIME_DIR. Tests that do not call them get the inherited value.

Direction

Remove these names in the package TestMain along with the directory overrides, so the default is the same machine with nothing overriding the home. Pin the list in the guard test the same way #1250 pins the directory names.

This was left out of #1250 on purpose, to keep that change to the directory redirection #1249 asks for.

The stray modelsdev-<digits>.json next to the cache may be worth a separate look: it suggests a temporary file from the cache write is not always removed.

Activity

  1. added
    bug
    on Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions