Skip to content

Fix data dir for Vercel serverless#26

Merged
gitgrahamdunn merged 1 commit intomainfrom
codex/fix-data-directory-for-vercel-deployment
Feb 18, 2026
Merged

Fix data dir for Vercel serverless#26
gitgrahamdunn merged 1 commit intomainfrom
codex/fix-data-directory-for-vercel-deployment

Conversation

@gitgrahamdunn
Copy link
Copy Markdown
Owner

Motivation

  • Import-time creation of .data under the repo caused OSError: [Errno 30] Read-only file system on Vercel because /var/task is read-only, so the data directory must be moved to a writable location.

Description

  • Change DEFAULT_DATA_DIR resolution to prefer the DATA_DIR environment variable and otherwise fall back to /tmp/gitplant-data so serverless functions can write to a writable path.
  • If a configured or computed candidate directory is inside the repository (REPO_ROOT), the code falls back to /tmp/gitplant-data to avoid writes under /var/task.
  • Keep idempotent directory creation with DEFAULT_DATA_DIR.mkdir(parents=True, exist_ok=True) so existing directories are fine and no extra behavior is changed.
  • Add a short comment that Vercel serverless functions run on a read-only filesystem except for /tmp to explain the rationale.

Testing

  • Ran python -m py_compile backend/app/config.py and it completed successfully.
  • No other automated tests were modified or run as part of this change.

Codex Task

@vercel
Copy link
Copy Markdown

vercel bot commented Feb 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
gitplant Ready Ready Preview, Comment Feb 18, 2026 10:01pm
gitplant-backend Ready Ready Preview, Comment Feb 18, 2026 10:01pm
gitplant-oggy Ready Ready Preview, Comment Feb 18, 2026 10:01pm

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cb4cddbd33

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread backend/app/config.py
candidate = Path("/tmp/gitplant-data")

try:
candidate.relative_to(REPO_ROOT)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Normalize DATA_DIR before enforcing repo-root fallback

The repo-root guard uses candidate.relative_to(REPO_ROOT) on the raw path, so DATA_DIR values containing traversal segments (for example /tmp/../var/task/.data or ../var/task/.data) are treated as outside the repo even when they resolve to /var/task/.... In that case _default_data_dir() returns a path under the read-only Vercel tree and DEFAULT_DATA_DIR.mkdir(...) can still fail at import time, which defeats the fix this commit is trying to provide. Resolve/canonicalize candidate before the relative_to check so equivalent paths inside REPO_ROOT are consistently redirected to /tmp.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant