Require NOCODB_BASE_ID: drop the baked-in fallback, fail with a clear message

- monitor.py: no default base id any more, and main() now reports whichever of
  NOCODB_TOKEN / NOCODB_BASE_ID is missing (writing the same text to
  /data/health.json) instead of dying inside bootstrap with a traceback
- docker-compose.yml: NOCODB_BASE_ID is a required variable now (production
  passes it in .env, so runtime behaviour is unchanged there)
- README: the contributing note matches reality again

Verified: python test_pagination.py passes, python -m py_compile clean, and a
run without the two variables prints "NOCODB_TOKEN, NOCODB_BASE_ID not set",
writes ok:false to health.json and exits 2.
This commit is contained in:
2026-10-06 16:54:45 +08:00
parent cb572a494c
commit 4c58d53b3c
3 changed files with 9 additions and 6 deletions
+1 -1
View File
@@ -415,7 +415,7 @@ Issues and pull requests are welcome. Two house rules before you send a patch:
1. **Open an issue first for anything beyond a typo** — this is a small, opinionated tool and the maintainer would rather agree on the shape before you write it.
2. **Do not break the tests.** `python test_pagination.py` must pass, and new behaviour wants a check added to it.
Please never commit credentials, host names or personal URLs. The repo intentionally ships no default base id, token or chat id.
Please never commit credentials, host names or personal URLs. The repo ships no base id, token or chat id — `NOCODB_BASE_ID` and `NOCODB_TOKEN` are required settings and the monitor refuses to start (with a clear message) until they are set.
## Credits
+1 -1
View File
@@ -14,7 +14,7 @@ services:
environment:
NOCODB_URL: ${NOCODB_URL:-http://nocodb:10380}
NOCODB_TOKEN: ${NOCODB_TOKEN}
NOCODB_BASE_ID: ${NOCODB_BASE_ID:-poqw1zjw3hnsk37}
NOCODB_BASE_ID: ${NOCODB_BASE_ID}
TELEGRAM_BOT_TOKEN: ${TELEGRAM_BOT_TOKEN}
TELEGRAM_CHAT_ID: ${TELEGRAM_CHAT_ID}
TICK_SECONDS: ${TICK_SECONDS:-60}
+7 -4
View File
@@ -31,7 +31,7 @@ import urllib.request
# --------------------------------------------------------------------------- #
NOCODB_URL = os.environ.get("NOCODB_URL", "http://nocodb:10380").rstrip("/")
NOCODB_TOKEN = os.environ.get("NOCODB_TOKEN", "")
NOCODB_BASE_ID = os.environ.get("NOCODB_BASE_ID", "poqw1zjw3hnsk37")
NOCODB_BASE_ID = os.environ.get("NOCODB_BASE_ID", "")
TELEGRAM_BOT_TOKEN = os.environ.get("TELEGRAM_BOT_TOKEN", "")
TELEGRAM_CHAT_ID = os.environ.get("TELEGRAM_CHAT_ID", "")
DATA_DIR = os.environ.get("DATA_DIR", "/data")
@@ -866,9 +866,12 @@ def run_tick(listings_tid, settings_tid, ignored_sellers_tid, ignored_keywords_t
def main():
if not NOCODB_TOKEN:
sys.stderr.write("NOCODB_TOKEN not set\n")
write_health(False, "NOCODB_TOKEN not set")
if not NOCODB_TOKEN or not NOCODB_BASE_ID:
missing = ", ".join(n for n, v in (("NOCODB_TOKEN", NOCODB_TOKEN),
("NOCODB_BASE_ID", NOCODB_BASE_ID))
if not v)
sys.stderr.write(f"{missing} not set\n")
write_health(False, f"{missing} not set")
sys.exit(2)
(listings_tid, settings_tid, ignored_sellers_tid, ignored_keywords_tid,