Skip to content

fix(config): one boolean vocabulary for every flag, and DB_TYPE case can no longer skip migrations - #346

Merged
GeiserX merged 2 commits into
mainfrom
ai/config-footguns
Aug 21, 2026
Merged

GeiserX merged 2 commits into
mainfrom
ai/config-footguns

Conversation

@GeiserX

@GeiserX GeiserX commented Aug 21, 2026 •

Copy link
Copy Markdown
Owner

Two config footguns that fail silently in opposite directions.

Thirteen boolean flags accepted only the literal string "true": DOWNLOAD_MEDIA=1 turned all media capture off, ENABLE_LISTENER=yes turned real-time capture off — no warning, nothing in the logs, while four sibling flags happily accepted 1/yes/on. And in the mirror direction, a typo on those four raised "Invalid boolean value: ture" without naming which variable carried the typo.

Every flag now parses one vocabulary (1/true/yes/on — 0/false/no/off) through a single parser, and a bad value names its variable in the error. scripts/entrypoint.sh additionally lower-cases DB_TYPE before matching, so DB_TYPE=PostgreSQL no longer falls through the exact-match into the no-migration path and boots the app on an unmigrated schema — an unrecognised DB config now refuses to start loudly instead.

Regression tests cover the full vocabulary on representative flags, the named-variable error, and the entrypoint case normalisation.

Summary by CodeRabbit

  • Bug Fixes
    • Database type settings are now handled consistently regardless of capitalization.
    • Unsupported or unrecognized database configurations now stop startup with a clear error instead of skipping migrations.
    • Boolean configuration values are validated consistently across all settings.
    • Invalid values now identify the affected configuration variable, making setup errors easier to diagnose.
    • Standard true/false values such as yes, no, on, and off are supported consistently.

…can no longer skip migrations

Thirteen flags parsed as .lower() == "true" accepted only that literal
string: DOWNLOAD_MEDIA=1 silently disabled all media capture,
ENABLE_LISTENER=yes silently disabled real-time capture — natural spellings,
because four sibling flags in the same file accepted 1/yes/on. Nothing was
logged; the run looked normal while capture degraded. The mirror flaw: a
typo in those four raised 'Invalid boolean value: ture' without naming the
variable.

All seventeen flags now parse through one named-variable helper accepting
1/true/yes/on and 0/false/no/off (case-insensitive) and rejecting anything
else with the variable named in the error. The one test that pinned
'nonsense means False' now pins the loud rejection instead.

entrypoint.sh compared DB_TYPE literally while Python lowercases it, so
DB_TYPE=PostgreSQL matched NEITHER branch — migrations silently skipped, app
started against a zero-table PostgreSQL. DB_TYPE is normalised once at the
top, and an unrecognised database configuration now refuses to start loudly
instead of falling through. shellcheck clean.
@coderabbitai

coderabbitai Bot commented Aug 21, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 45a2ccc9-149b-4242-ba45-62d2c43445dd

📥 Commits

Reviewing files that changed from the base of the PR and between c59e7cb and 42cfc44.

📒 Files selected for processing (4)
  • scripts/entrypoint.sh
  • src/config.py
  • tests/test_config_bool_vocab.py
  • tests/test_gap_fill.py

Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The change centralizes boolean environment parsing, applies it across configuration flags, improves invalid-value errors, and adds validation for unsupported database types before startup continues.

Changes

Configuration validation

Layer / File(s) Summary
Shared boolean environment parsing
src/config.py, tests/test_config_bool_vocab.py, tests/test_gap_fill.py
Boolean flags use shared 1/true/yes/on and 0/false/no/off values. Invalid values raise ValueError with the environment variable name.
Database startup validation
scripts/entrypoint.sh, tests/test_config_bool_vocab.py
DB_TYPE is lowercased before comparison. Unsupported values now terminate startup with status 1.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 42cfc

The configuration changes standardize boolean parsing and safely normalize DB_TYPE matching while preserving unset handling. No actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the main changes and regression coverage but omits most required template sections and checklist information. Add the Type of Change, Database Changes, Data Consistency, Testing, Security, and Deployment Notes sections with applicable checkboxes and details.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the unified boolean parsing and DB_TYPE migration safety changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ai/config-footguns

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

🐳 Dev images published!

  • drumsergio/telegram-archive:dev
  • drumsergio/telegram-archive-viewer:dev

The dev/test instance will pick up these changes automatically (Portainer GitOps).

To test locally:

docker pull drumsergio/telegram-archive:dev
docker pull drumsergio/telegram-archive-viewer:dev

@github-actions

Copy link
Copy Markdown

🐳 Dev images published!

  • drumsergio/telegram-archive:dev
  • drumsergio/telegram-archive-viewer:dev

The dev/test instance will pick up these changes automatically (Portainer GitOps).

To test locally:

docker pull drumsergio/telegram-archive:dev
docker pull drumsergio/telegram-archive-viewer:dev

@codecov

codecov Bot commented Aug 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.76%. Comparing base (1e6172b) to head (42cfc44).
⚠️ Report is 12 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #346      +/-   ##
==========================================
+ Coverage   93.74%   93.76%   +0.01%     
==========================================
  Files          27       27              
  Lines        9963     9977      +14     
==========================================
+ Hits         9340     9355      +15     
+ Misses        623      622       -1     
Files with missing lines Coverage Δ
src/config.py 94.50% <100.00%> (+0.23%) ⬆️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@GeiserX

GeiserX commented Aug 21, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@GeiserX
GeiserX merged commit 35fb6f9 into main Aug 21, 2026
11 checks passed
@GeiserX
GeiserX deleted the ai/config-footguns branch August 21, 2026 12:23
GeiserX added a commit that referenced this pull request Oct 2, 2026
…can no longer skip migrations (#346)

* fix(config): one boolean vocabulary for every flag, and DB_TYPE case can no longer skip migrations

Thirteen flags parsed as .lower() == "true" accepted only that literal
string: DOWNLOAD_MEDIA=1 silently disabled all media capture,
ENABLE_LISTENER=yes silently disabled real-time capture — natural spellings,
because four sibling flags in the same file accepted 1/yes/on. Nothing was
logged; the run looked normal while capture degraded. The mirror flaw: a
typo in those four raised 'Invalid boolean value: ture' without naming the
variable.

All seventeen flags now parse through one named-variable helper accepting
1/true/yes/on and 0/false/no/off (case-insensitive) and rejecting anything
else with the variable named in the error. The one test that pinned
'nonsense means False' now pins the loud rejection instead.

entrypoint.sh compared DB_TYPE literally while Python lowercases it, so
DB_TYPE=PostgreSQL matched NEITHER branch — migrations silently skipped, app
started against a zero-table PostgreSQL. DB_TYPE is normalised once at the
top, and an unrecognised database configuration now refuses to start loudly
instead of falling through. shellcheck clean.

* style(tests): satisfy ruff import order and SIM117 on the new config tests
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.

1 participant