Skip to content

chore(deploy): Gate hosted SQLite recovery behind explicit flag #31#32

Merged
mathemage merged 15 commits into
mainfrom
chore/sqlite-emergency-fallback-31
Apr 19, 2026
Merged

chore(deploy): Gate hosted SQLite recovery behind explicit flag #31#32
mathemage merged 15 commits into
mainfrom
chore/sqlite-emergency-fallback-31

Conversation

@mathemage

Copy link
Copy Markdown
Owner

Summary

  • require an explicit DJANGO_ENABLE_HOSTED_SQLITE_FALLBACK=1 opt-in before hosted SQLite recovery activates
  • keep normal hosted deployments fail-fast when DATABASE_URL is missing or invalid
  • document the emergency-only recovery mode and add regression coverage around the flag

Why

The SQLite rescue path is useful during an outage, but it should never activate silently during normal hosted deploys. This PR keeps the recovery option available while making it a deliberate operator choice.

Closes #31

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@vercel

vercel Bot commented Apr 18, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
deep-workflow Error Error Apr 19, 2026 5:35pm

Copilot AI review requested due to automatic review settings April 18, 2026 00:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR makes the hosted “SQLite recovery” behavior an explicit operator opt-in by introducing DJANGO_ENABLE_HOSTED_SQLITE_FALLBACK, and documents/tests the intended emergency-only workflow for Vercel-hosted deployments.

Changes:

  • Add DJANGO_ENABLE_HOSTED_SQLITE_FALLBACK and compute HOSTED_SQLITE_FALLBACK to gate cookie-backed sessions/messages in hosted + SQLite mode.
  • Add regression tests asserting the hosted SQLite fallback is off by default and only activates when explicitly enabled.
  • Document the emergency hosted SQLite recovery mode and the new environment variable.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
deep_workflow/settings.py Introduces DJANGO_ENABLE_HOSTED_SQLITE_FALLBACK and gates cookie-backed session/message backends behind a hosted+SQLite+flag condition.
core/tests/test_deployment.py Adds subprocess-based tests to validate the new flag behavior in settings import-time logic.
README.md Documents the emergency-only flag and explains when/how to use hosted SQLite recovery.

Comment thread deep_workflow/settings.py
Comment thread core/tests/test_deployment.py Outdated
Comment thread core/tests/test_deployment.py
Comment thread README.md Outdated
@mathemage

Copy link
Copy Markdown
Owner Author

@copilot apply changes based on the comments in this thread

Resolve all discussions at #32 (review) when each comment is tackled.

Copilot AI review requested due to automatic review settings April 18, 2026 00:43
@mathemage mathemage removed the request for review from Copilot April 18, 2026 00:43

Copilot AI commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

@copilot apply changes based on the comments in this thread

Resolve all discussions at https://g...

All 4 review discussions addressed in commits 36cf212 and f90ebe3:

  1. settings.py — added fail-fast ImproperlyConfigured raise when HOSTED_ENV is true and DB engine is SQLite but HOSTED_SQLITE_FALLBACK is false, so normal hosted deploys can never silently use SQLite.

  2. test_deployment.py (143-149)load_hosted_settings() now emits native JSON booleans instead of str(bool), return type updated to tuple[bool, str, str], and assertions use is True / is False.

  3. test_deployment.py (172-179)test_hosted_sqlite_fallback_is_disabled_by_default now expects subprocess failure (ImproperlyConfigured in stderr, non-zero exit code); added test_hosted_sqlite_fallback_flag_ignored_for_postgresql asserting HOSTED_SQLITE_FALLBACK stays False and session/message backends are unchanged when DATABASE_URL is PostgreSQL.

  4. README.md (189) — expanded the emergency recovery note with the cookie size and signed-cookie readability warning.

Helper also renamed from load_hosted_sqlite_settingsload_hosted_settings since it now covers both SQLite and PostgreSQL URLs.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread core/tests/test_deployment.py
Comment thread core/tests/test_deployment.py Outdated
Comment thread deep_workflow/settings.py Outdated
@mathemage

Copy link
Copy Markdown
Owner Author

@copilot apply changes based on the comments in this thread

Resolve discussion at #32 (review) once each comment is fixed

Copilot AI commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

@copilot apply changes based on the comments in this thread

Resolve discussion at https://github.com/mathe...

Fixed in 6815141.

The hosted SQLite guard message now explicitly says hosted deploys require a valid PostgreSQL DATABASE_URL unless the emergency fallback flag is enabled. The failure regression test now asserts on that specific message content, and there is a new test covering the default-disabled behavior when DJANGO_ENABLE_HOSTED_SQLITE_FALLBACK is unset.

Validation passed with ruff check ., ruff format --check ., python manage.py check, pytest, and final review/security validation.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread core/tests/test_deployment.py Outdated
Comment thread deep_workflow/settings.py Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread core/tests/test_deployment.py Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread core/tests/test_deployment.py Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread deep_workflow/settings.py Outdated
(1) PostgreSQL `DATABASE_URL`, or (2) `DJANGO_ENABLE_HOSTED_SQLITE_FALLBACK=1` + a SQLite `DATABASE_URL` (emergency only)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 19, 2026 17:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread core/tests/test_deployment.py
Comment thread core/tests/test_deployment.py Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@mathemage mathemage merged commit 5834dc6 into main Apr 19, 2026
7 of 8 checks passed
@mathemage mathemage deleted the chore/sqlite-emergency-fallback-31 branch April 19, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(deploy): Gate hosted SQLite recovery behind explicit emergency flag

3 participants