Skip to content

Trust /data/uploads so Claude stops asking at every start (2.5.9) - #91

Merged
ESJavadex merged 2 commits into
ESJavadex:mainfrom
nsleigh:fix/trust-upload-dir
Nov 25, 2026
Merged

ESJavadex merged 2 commits into
ESJavadex:mainfrom
nsleigh:fix/trust-upload-dir

Conversation

@nsleigh

@nsleigh nsleigh commented Nov 18, 2026 •

Copy link
Copy Markdown

Fixes #90.

Problem

From Claude Code 2.1.327, every new Claude session in the add-on stops at "Adding a new directory: /data/uploads ... Is this a directory you created or one you trust?". The add-on starts Claude with --add-dir /data/uploads (from the first window and the session picker), and Claude now asks about each added folder that has no trust record. The answer holds only for that session, so it comes back at every start.

Fix

A new start-up step, trust_upload_dir in run.sh (after setup_statusline), records the folder in ~/.claude.json (/data/home/.claude.json):

"projects": { "/data/uploads": { "hasTrustDialogAccepted": true } }

That's the record Claude writes when its trust prompt is accepted, and the one Claude checks before asking: the folder or one above it must have it. Claude's own error messages also suggest setting it by hand.

  • Only /data/uploads. Not /data, which would also cover /data/home and the login.
  • The rest of the file is kept. Other projects, the account and settings are untouched, and an entry already there for the folder keeps its other keys.
  • A failed write can't cut the file short. The update goes to a copy beside the file, which starts as cp -p of it (so it keeps the owner and permissions), and is renamed into place only once it is written. If any step fails, the copy is removed and the original is left as it was. A new file is created with mode 600, and a symlinked file stays a symlink.
  • An explicit hasTrustDialogAccepted: false is kept. That is a choice made in Claude, so the step leaves it and logs that the folder stays untrusted.
  • A file jq can't parse is never rewritten. Claude may restore it from a backup, so the step only logs a warning.
  • Nothing is written when the folder is already trusted.
  • Safe to trust: the image service saves uploads flat, with cleaned-up, time-stamped names. No .claude settings folder can appear in /data/uploads.

DOCS ("Giving Claude Files"), CLAUDE.md (start-up steps) and the CHANGELOG describe it. Version 2.5.9.

Tests

test-production-run.sh:

  • a missing ~/.claude.json is created with the entry, mode 600;
  • an existing file gets the entry and keeps its other keys, its other projects, the folder's existing keys and its permissions (640 stays 640);
  • only /data/uploads is added;
  • a second run leaves the file unchanged;
  • invalid JSON is left exactly as it was;
  • an explicit hasTrustDialogAccepted: false is left exactly as it was;
  • a write that fails partway (a stubbed write that leaves a cut-off file, then fails) leaves the original whole, with no temporary copy behind;
  • a symlinked ~/.claude.json stays a symlink, and the file it points to gets the entry;
  • main() runs the step.

tests/run-tests.sh and shellcheck pass.

Tested

On my Home Assistant (as a separate dev add-on, Claude Code 2.1.327):

  • the start-up log shows "Marked /data/uploads as a trusted folder for Claude";
  • Claude starts without the trust question;
  • an uploaded file is read without asking.

After the review changes (2.5.9, Claude Code 2.1.330):

  • with the entry removed, a restart logs "Marked /data/uploads as a trusted folder for Claude". The file keeps its owner and mode (root, 600), no temporary copy is left behind, and Claude starts without the trust question;
  • with an explicit hasTrustDialogAccepted: false, a restart logs that the folder stays untrusted, the file still says false, and Claude asks the trust question.

🤖 Generated with Claude Code

@ESJavadex ESJavadex left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Neil, for tracking this down and testing it on an actual Home Assistant install. Scoping the trust record to the upload directory is helpful.

Could we write the updated config to a temporary file beside the original and rename it into place once the write succeeds? The current redirection can truncate the whole Claude config if the write fails partway through. Could we also preserve an explicitly stored hasTrustDialogAccepted: false? That keeps an existing trust choice meaningful. Please cover both cases in the regression tests.

#93 uses 2.5.8 for the OAuth notification fix and the scheduled build failure. This patch can take the next version after rebasing on main.

Record projects["/data/uploads"].hasTrustDialogAccepted in ~/.claude.json at
start-up. The update is written to a copy beside the file and renamed into
place, so a failed write can't cut the file short; an explicit false is kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nsleigh
nsleigh force-pushed the fix/trust-upload-dir branch from 438728e to 6653462 Compare November 25, 2026 01:45
@nsleigh

nsleigh commented Nov 25, 2026

Copy link
Copy Markdown
Author

Thanks, Javier, both done, and rebased on main as 2.5.9.

  • The update now goes to a copy beside ~/.claude.json and is renamed into place once the write succeeds. The copy starts as cp -p of the original, so it keeps the owner and permissions. If any step fails, the copy is removed and the original is untouched. A symlinked file stays a symlink.
  • An explicit hasTrustDialogAccepted: false is kept: the step leaves the file alone and logs that the folder stays untrusted.

New regression tests cover both: an explicit false is left byte for byte, and a write that fails partway (a stub that writes a cut-off file and then fails) leaves the original whole with no temporary copy behind. There's also one for the symlink case.

I've also retested both on my Home Assistant; the PR description's Tested section has the details. One thing I noticed while testing: a Claude that's already running can write its own copy of ~/.claude.json back over the file, so a hand edit made while Claude runs may not survive. The start-up step runs before any Claude starts, so it isn't affected.

@nsleigh nsleigh changed the title Trust /data/uploads so Claude stops asking at every start (2.5.8) Trust /data/uploads so Claude stops asking at every start (2.5.9) Nov 25, 2026

@ESJavadex ESJavadex left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix and for testing it on Home Assistant, Neil. I verified that the trust entry is limited to /data/uploads and that an explicit refusal is preserved. I tightened the config reader to require a single JSON object, with regression coverage for whitespace, null and multiple documents. The updated tests pass in the lab container.

@ESJavadex
ESJavadex merged commit f787f40 into ESJavadex:main Nov 25, 2026
7 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.

Claude asks to trust /data/uploads at every start (Claude Code 2.1.327)

2 participants