Some checks failed
Run Tests / test (push) Failing after 5m2s
- Introduced a new template for currency overview and management (`currencies.html`). - Updated footer to include attribution to AllYouCanGET. - Added "Currencies" link to the main navigation header. - Implemented end-to-end tests for currency creation, update, and activation toggling. - Created unit tests for currency API endpoints, including creation, updating, and activation toggling. - Added a fixture to seed default currencies for testing. - Enhanced database setup tests to ensure proper seeding and migration handling.
2.3 KiB
2.3 KiB
Setup Script Logging Audit (2025-10-25)
The following observations capture current logging behaviour in scripts/setup_database.py and highlight areas requiring improved error handling and messaging.
Connection Validation
validate_admin_connectionandvalidate_application_connectionlog entry/exit messages and raiseRuntimeErrorwith context if connection fails. This coverage is sufficient.ensure_databaselogs creation states but does not surface connection or SQL exceptions beyond the initial connection acquisition. When the innercursor.executecalls fail, the exceptions bubble without contextual logging.
Migration Runner
- Lists pending migrations and logs each application attempt.
- When the baseline is pending, the script logs whether it is a dry-run or live application and records legacy file marking. However, if
_apply_migration_fileraises an exception, the caller re-raises after logging the failure; there is no wrapping message guiding users toward manual cleanup. - Legacy migration marking happens silently (just info logs). Failures during the insert into
schema_migrationswould currently propagate without added guidance.
Seeding Workflow
seed_baseline_dataannounces each seeding phase and skips verification in dry-run mode with a log breadcrumb._verify_seeded_datawarns about missing currencies/units and inactive defaults but does not raise errors, meaning CI can pass while the database is incomplete. There is no explicit log when verification succeeds._seed_unitslogs when themeasurement_unittable is missing, which is helpful, but the warning is the only feedback; no exception is raised.
Suggested Enhancements
- Wrap baseline application and legacy marking in
try/exceptblocks that log actionable remediation steps before re-raising. - Promote seed verification failures (missing or inactive records) to exceptions so automated workflows fail fast; add success logs for clarity.
- Add contextual logging around currency/measurement-unit insert failures, particularly around
execute_valuescalls, to aid debugging malformed data. - Introduce structured logging (log codes or phases) for major steps (
CONNECT,MIGRATE,SEED,VERIFY) to make scanning log files easier.
These findings inform the remaining TODO subtasks for enhanced error handling.