Skip to content

fix(workspace): list --json past the argument size limit; isolate test registry - #102

Merged
simensen merged 1 commit into
mainfrom
fix/workspace-list-json-arg-limit
Nov 11, 2026
Merged

simensen merged 1 commit into
mainfrom
fix/workspace-list-json-arg-limit

Conversation

@simensen

Copy link
Copy Markdown
Member

Summary

xcind-workspace list --json failed with jq: Argument list too long when the workspace registry was large. This PR fixes the command and the test-suite leak that made the registry large.

Cause

  • Argument size limit. The command passed the full workspace array to jq as one --argjson value. Linux limits a single argument to 128 KiB (MAX_ARG_STRLEN). A registry of about 1,950 rows was larger than that limit.
  • Test fixtures in the real registry. Workspace discovery registers each workspace that it finds. The tests did not isolate the registry, so each test run added its tempdir fixtures to the developer's real ~/.local/state/xcind/workspaces.tsv. In the observed case, 1,946 of 1,949 rows were stale /tmp paths.

Changes

  • bin/xcind-workspace: list --json writes one TSV row per workspace to the stdin of a single jq -nR. The JSON no longer goes through an argument. The command also starts one jq process instead of one per row. The output shape does not change.
  • test/lib/setup.sh: exports XDG_STATE_HOME under the test temp root and rebinds the XCIND_REGISTRY_* globals. The test files source xcind-lib.bash before this file, so the globals had the real path.
  • test/test-xcind-proxy.sh: REAL_HOME is now a sandbox directory. This file unsets XDG_STATE_HOME, and its blocks "restore" HOME through REAL_HOME. Before this change, the later xcind-workspace init/status tests wrote to the real registry.

Verification

  • make check passes.
  • The real registry has the same row count before and after a full make test run. Before the fix, each run added rows.
  • xcind-workspace list --json returns valid JSON for a registry of 1,949 rows.

Note for developers

To remove stale rows from an earlier test run, use xcind-workspace list --prune.

…t registry

xcind-workspace list --json passed the assembled workspace array to jq
through --argjson. Linux caps a single argument at 128 KiB
(MAX_ARG_STRLEN), so a registry of about two thousand entries failed
with "Argument list too long". Stream one TSV row per workspace into a
single jq on stdin instead. This also replaces one jq spawn per row.
The output shape is unchanged.

The registry grew that large because the test suite registered its
tempdir fixtures in the developer's real workspaces.tsv:

- The test files source xcind-lib.bash, which computes the registry
  path from the real XDG_STATE_HOME/HOME. test/lib/setup.sh now
  exports XDG_STATE_HOME under the test temp root and rebinds the
  registry globals.
- test-xcind-proxy.sh unsets XDG_STATE_HOME and "restores" HOME to
  the real home between blocks, so later xcind-workspace init/status
  tests wrote to the real registry. REAL_HOME is now a sandbox.

Existing stale rows can be removed with xcind-workspace list --prune.
@simensen
simensen merged commit 78d875c into main Nov 11, 2026
16 of 17 checks passed
@simensen
simensen deleted the fix/workspace-list-json-arg-limit branch November 11, 2026 15:17
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