Skip to content

Fix writeToFile -1700 type coercion error on file close#25

Open
weijianfan wants to merge 1 commit intostorizzi:mainfrom
weijianfan:fix/writeto-file-close-access
Open

Fix writeToFile -1700 type coercion error on file close#25
weijianfan wants to merge 1 commit intostorizzi:mainfrom
weijianfan:fix/writeto-file-close-access

Conversation

@weijianfan
Copy link
Copy Markdown

Summary

  • close access was called without an argument, causing AppleScript to close "current application" instead of the file descriptor, resulting in a -1700 type coercion error
  • Fixed close accessclose access fileDescriptor
  • Added set eof of fileDescriptor to 0 before writing to cleanly truncate existing files
  • Added shell fallback via printf if AppleScript file access fails
  • Added do shell script "touch ..." before open for access to ensure the file exists upfront

Test plan

  • Export notes and verify files are written without -1700 error
  • Test with pre-existing files to verify clean truncation
  • Verify shell fallback triggers gracefully if AppleScript file access fails

🤖 Generated with Claude Code

@sai3563
Copy link
Copy Markdown

sai3563 commented Mar 29, 2026

Why is this PR diff in an opaque binary blob format that cannot be reviewed when the original file itself can be read as plain text?

There are way too many supply chain attacks going on these days that fall though the OSS review process cracks because of binary blobs.

Ironically, Claude Code itself calls this suspicious and here is it's suggestion:

This may be a real fix, but the submission format is wrong. Please resubmit the change as plain-text AppleScript matching the existing repository format, not as a compiled .scpt blob

@sai3563
Copy link
Copy Markdown

sai3563 commented Mar 29, 2026

Also, from the description alone(since I cannot see source code), it seems my PR raised before at least partly does the same thing.

https://github.com/storizzi/notes-exporter/pull/24/changes

Use Foundation NSString writeToFile: as the primary write method to
avoid the -1700 type coercion error that occurs when calling
`close access` on a file descriptor. Add a safe AppleScript fallback
that tracks the file descriptor and only calls `close access` when
the file was successfully opened.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@weijianfan weijianfan force-pushed the fix/writeto-file-close-access branch from 06853d2 to 68818d1 Compare March 29, 2026 12:29
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.

2 participants