Skip to content

Fix tarball permission stripping and allowedTools flag format#149

Merged
ElleNajt merged 1 commit intomainfrom
fix/tar-permissions
Feb 3, 2026
Merged

Fix tarball permission stripping and allowedTools flag format#149
ElleNajt merged 1 commit intomainfrom
fix/tar-permissions

Conversation

@ElleNajt
Copy link
Contributor

@ElleNajt ElleNajt commented Feb 3, 2026

Summary

  • Simplify _tar_inputs() to use tarfile.add() directly (preserves permissions by default)
  • Fix --allowedTools CLI flag quoting using shlex.quote()
  • Remove unnecessary mtime/uid/gid normalization (in-memory cache is sufficient)

Problem

The tarball creation was hardcoding all files to 0o644, stripping executable permissions. This caused Claude Code to see spurious 100755 -> 100644 permission changes when running git diff HEAD~1 --raw, leading to false positives.

Fix

Simplified from complex manual TarInfo construction to just:

def _tar_inputs(self, inputs: dict[str, Path], tar_path: Path) -> None:
    """Create a gzipped tarball from inputs, preserving file permissions."""
    with tarfile.open(tar_path, "w:gz") as tar:
        for name, local_path in sorted(inputs.items()):
            local_path = Path(local_path).expanduser().resolve()
            if not local_path.exists():
                raise CloudRunClientError(f"Input not found: {local_path}")
            tar.add(local_path, arcname=name)

This preserves file permissions naturally. The in-memory cache (keyed by path names) already prevents duplicate uploads within a process, so we dont need deterministic tarball hashes for GCS deduplication.

Test plan

  • Permission preservation test passes (5 different modes: 0o755, 0o700, 0o750, 0o644, 0o444)
  • In-memory caching tests pass
  • Thread safety tests pass
  • Removed obsolete deterministic tarring tests (no longer needed)

🤖 Generated with Claude Code

@ElleNajt ElleNajt force-pushed the fix/tar-permissions branch 5 times, most recently from df32b8b to 632dd38 Compare February 3, 2026 01:19
1. Preserve full file permissions in _tar_inputs(): Files now retain
   their complete mode (rwx bits) instead of being normalized.
   Only mtime/uid/gid are normalized for reproducibility.

2. Fix --allowedTools flag format: Use shlex.quote() for proper
   shell escaping instead of manual quoting.

3. Add test for full permission mode preservation after tar round-trip.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@ElleNajt ElleNajt force-pushed the fix/tar-permissions branch from 632dd38 to 1ec86a6 Compare February 3, 2026 01:25
@ElleNajt ElleNajt merged commit a618043 into main Feb 3, 2026
2 checks passed
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