Skip to content

Vercel: use /tmp for data dir#27

Merged
gitgrahamdunn merged 1 commit intomainfrom
codex/fix-serverless-crash-on-vercel
Feb 18, 2026
Merged

Vercel: use /tmp for data dir#27
gitgrahamdunn merged 1 commit intomainfrom
codex/fix-serverless-crash-on-vercel

Conversation

@gitgrahamdunn
Copy link
Copy Markdown
Owner

Motivation

  • Prevent import-time OSError: [Errno 30] Read-only file system on serverless platforms (Vercel) by avoiding creating directories inside the deployed code folder.
  • Preserve existing override via the DATA_DIR env var while defaulting to a writable location when not provided.

Description

  • Add _ensure_writable_data_dir(path: Path) to attempt mkdir and fall back to "/tmp/gitplant-data" on OSError during import-time initialization.
  • Use _default_data_dir() (which still honors DATA_DIR and prefixes relative paths with /tmp) together with the new helper to set DEFAULT_DATA_DIR.
  • Move default DEFAULT_STORAGE_DIR and DEFAULT_PLANT_STORAGE_DIR to live under the resolved DEFAULT_DATA_DIR instead of the repository storage folder.
  • Do not change route or business logic; only change default storage path resolution and make directory creation resilient.

Testing

  • Ran python -m compileall backend/app/config.py which completed successfully.
  • Performed an import smoke check with python - <<'PY' ... from backend.app.config import DEFAULT_DATA_DIR, DEFAULT_STORAGE_DIR, DEFAULT_PLANT_STORAGE_DIR ... PY which printed the resolved /tmp-based paths and succeeded.

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:13pm
gitplant-backend Ready Ready Preview, Comment Feb 18, 2026 10:13pm
gitplant-oggy Ready Ready Preview, Comment Feb 18, 2026 10:13pm

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: d9839f9b67

ℹ️ 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
Comment on lines +33 to +36
except OSError:
fallback = Path("/tmp/gitplant-data")
fallback.mkdir(parents=True, exist_ok=True)
return fallback
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Don't ignore configured DATA_DIR on mkdir errors

If DATA_DIR is explicitly set but path.mkdir(...) fails (for example, the target is a file path or a mounted volume is not writable at startup), this branch silently falls back to /tmp/gitplant-data and continues. That causes the app to write DB/files to ephemeral storage while operators believe the configured persistent path is in use, which can lead to apparent data loss after restarts. Consider failing fast (or at least surfacing an error) when a user-provided DATA_DIR cannot be created, and reserve fallback for implicit defaults.

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