Skip to content

fix(a2a): add cross-platform atomic write safety & handle Windows chm… - #85

Open
Adityakk9031 wants to merge 1 commit into
inkbox-ai:mainfrom
Adityakk9031:#84
Open

fix(a2a): add cross-platform atomic write safety & handle Windows chm…#85
Adityakk9031 wants to merge 1 commit into
inkbox-ai:mainfrom
Adityakk9031:#84

Conversation

@Adityakk9031

@Adityakk9031 Adityakk9031 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Fixes #84

Summary

Fixes an issue in a2a_context.py where _atomic_write raised unhandled OSError / PermissionError on Windows environments during chmod(0o600) calls, and left temporary .tmp context files dangling when atomic writes were interrupted.

Problem

  1. Windows Compatibility: POSIX file permissions (chmod(0o600)) throw OSError / PermissionError on Windows or non-POSIX file systems.
  2. Leftover Temp Files: If _atomic_write failed prior to os.replace, the .tmp file was left in the state directory, causing subsequent os.replace calls to fail with PermissionError or file lock conflicts.

Fix Applied

  • Cross-Platform Safety: Wrapped POSIX chmod(0o600) calls in contextlib.suppress(OSError) so file creation succeeds across Windows and non-POSIX environments.
  • Guaranteed Cleanup: Added a finally block in _atomic_write to safely unlink any leftover .tmp file on failure.
  • Explicit Encoding: Specified encoding="utf-8" when writing JSON context files.

Verification

  • Executed unit test suite for A2A context management:
    python -m pytest tests/test_a2a.py

@Adityakk9031

Copy link
Copy Markdown
Contributor Author

@dimavrem22 and @alex-w-99 have a look

@dimavrem22

Copy link
Copy Markdown
Contributor

@dimavrem22 and @alex-w-99 have a look

thanks @Adityakk9031 to help us review the prs, can you please let us know the agent handle of the identity you're using. Thanks mate

@Adityakk9031

Adityakk9031 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

@dimavrem22 Thanks I used OpenCode together with Codex as coding assistants for this PR. I reviewed and finalized the changes before submitting.

@dimavrem22

Copy link
Copy Markdown
Contributor

@dimavrem22 Thanks I used OpenCode together with Codex as coding assistants for this PR. I reviewed and finalized the changes before submitting.

no i mean your inkbox agent handle

@Adityakk9031

Adityakk9031 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

@dimavrem22 Ah got it, thanks for clarifying! My Inkbox agent handle is adityakk.

@dimavrem22

Copy link
Copy Markdown
Contributor

@dimavrem22 Ah got it, thanks for clarifying! My Inkbox agent handle is adityakk.

nice! How'd you run into this issue out of curiosity? did you run A2A on a windows? Im thinking of ways to harden the code against issues like this in the future

@Adityakk9031

Copy link
Copy Markdown
Contributor Author

Thanks @dimavrem22! Yes, exactly I was running the plugin and running test suites on a Windows machine.

On Windows/NTFS, POSIX chmod(0o600) calls raise PermissionError/OSError. Since there wasn't a finally block to clean up the .tmp file when chmod failed, subsequent os.replace attempts hit file lock conflicts.

Adding cross-platform CI matrix testing (windows-latest alongside Linux) in GitHub Actions would be a great way to catch OS-specific file system edge cases automatically!

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.

Unhandled Non-Atomic File Operations & Permission Crashes in A2A Context State Persistence (a2a_context.py)

2 participants