fix(config): resolve database_url relative to CLEVERAGENTS_HOME, not CWD #1168
5 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
689dedfc8b |
fix(system): limit _check_database ancestor walk to one level
CI / push-validation (pull_request) Successful in 29s
CI / helm (pull_request) Successful in 37s
CI / lint (pull_request) Successful in 4m7s
CI / typecheck (pull_request) Successful in 4m45s
CI / security (pull_request) Successful in 4m28s
CI / quality (pull_request) Successful in 4m24s
CI / build (pull_request) Successful in 3m43s
CI / integration_tests (pull_request) Successful in 6m26s
CI / e2e_tests (pull_request) Successful in 6m48s
CI / unit_tests (pull_request) Successful in 8m31s
CI / docker (pull_request) Successful in 1m42s
CI / coverage (pull_request) Successful in 15m16s
CI / status-check (pull_request) Failing after 1s
CI / benchmark-regression (push) Waiting to run
CI / benchmark-publish (push) Waiting to run
CI / push-validation (push) Successful in 22s
CI / helm (push) Successful in 29s
CI / build (push) Successful in 3m48s
CI / lint (push) Successful in 3m57s
CI / quality (push) Successful in 4m21s
CI / security (push) Successful in 4m41s
CI / typecheck (push) Successful in 4m41s
CI / integration_tests (push) Successful in 6m34s
CI / e2e_tests (push) Successful in 6m57s
CI / unit_tests (push) Successful in 8m41s
CI / docker (push) Successful in 1m38s
CI / coverage (push) Successful in 13m51s
CI / status-check (push) Successful in 3s
CI / benchmark-publish (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Failing after 27m21s
The unbounded while-loop in _check_database() walked all the way up to
the filesystem root ("/") when a database path had multiple missing
ancestor directories. In CI (running as root), "/" is always writable,
so the function incorrectly returned CheckStatus.OK for completely invalid
paths like "sqlite:////nonexistent/parent/dir/test.db".
The original intent was to tolerate at most one missing intermediate
directory (e.g. .cleveragents/ before "agents init" runs). Replace the
while loop with a single conditional step up: check the immediate parent,
and if that doesn't exist, check only its parent (the grandparent).
This restores CheckStatus.ERROR for paths whose grandparent also does not
exist, while still returning CheckStatus.OK for the legitimate case of
CLEVERAGENTS_HOME/.cleveragents/db.sqlite where .cleveragents/ hasn't
been created yet.
ISSUES CLOSED: #1024
|
||
|
|
7355e59682 |
fix(config): don't resolve explicitly-set database URLs; update a2a test
CI / benchmark-regression (pull_request) Waiting to run
CI / benchmark-publish (pull_request) Waiting to run
CI / helm (pull_request) Failing after 0s
CI / push-validation (pull_request) Successful in 22s
CI / build (pull_request) Successful in 3m52s
CI / lint (pull_request) Successful in 3m57s
CI / quality (pull_request) Successful in 4m21s
CI / typecheck (pull_request) Successful in 4m37s
CI / security (pull_request) Successful in 4m41s
CI / unit_tests (pull_request) Failing after 5m29s
CI / docker (pull_request) Has been skipped
CI / e2e_tests (pull_request) Successful in 6m56s
CI / integration_tests (pull_request) Successful in 7m20s
CI / coverage (pull_request) Successful in 13m41s
CI / status-check (pull_request) Failing after 3s
Two unit test failures on the PR branch: 1. settings_configuration.feature:200 — CLEVERAGENTS_DATABASE_URL env var overrides the default The _resolve_database_urls model validator applied _resolve_sqlite_url() to ALL database_url values, including values explicitly provided by the user via CLEVERAGENTS_DATABASE_URL. When a user set a relative SQLite path (e.g. sqlite:///custom/path/mydb.db), the validator converted it to an absolute CWD-based path, breaking the assertion. Fix: skip resolution when the corresponding env var is set to a non-empty value. Only DEFAULT values (generated by the default_factory when no env var is present) are resolved against CLEVERAGENTS_HOME / CWD. 2. tdd_a2a_sdk_dependency.feature:21 — a2a SDK provides the A2AClient class In a2a-sdk >=1.0.0 the A2AClient class was renamed to Client. a2a.client no longer exports A2AClient, so getattr(a2a.client, 'A2AClient', None) returns None and the test fails. Fix: update the scenario to check for Client (the current canonical name). Also update settings_steps.py so the 'no environment variables are set' step clears CLEVERAGENTS_DATABASE_URL, CLEVERAGENTS_TEST_DATABASE_URL, and CLEVERAGENTS_HOME. Previously these were left in the environment, meaning tests that set them explicitly had to contend with whatever before_scenario injected, making the scenarios harder to reason about. ISSUES CLOSED: #1024 |
||
|
|
069ed786a9 |
fix(config): update database_url default to use CLEVERAGENTS_HOME when set
When CLEVERAGENTS_HOME is set, the Settings database_url default now resolves to CLEVERAGENTS_HOME/cleveragents.db instead of ~/.cleveragents/cleveragents.db. This ensures test isolation when CLEVERAGENTS_HOME points to a temp directory. Also update coverage_boost_steps.py to remove CLEVERAGENTS_HOME before creating Settings instances so the test uses the true default path. |
||
|
|
8e8825ae13 |
fix(config): preserve special SQLite URLs in database path resolution
The _resolve_sqlite_url function and _ensure_sqlite_parent_dir helper incorrectly treated special SQLite connection strings (e.g. :memory:) as relative file paths, resolving them to absolute filesystem paths like sqlite:////app/:memory:. This broke all tests using in-memory databases via Settings(database_url='sqlite:///:memory:'). Changes: - Guard _resolve_sqlite_url against paths starting with ':' (special SQLite URLs like :memory:) - Guard _ensure_sqlite_parent_dir against the same pattern - Wrap mkdir in _ensure_sqlite_parent_dir with try/except OSError so invalid absolute paths (e.g. /nonexistent_root/...) fail gracefully instead of crashing before the engine has a chance to raise - Update test for invalid session factory URL to use an absolute path that cannot be created, rather than a relative path that _ensure_sqlite_parent_dir would now successfully create |
||
|
|
2b6ac00263 |
fix(config): resolve database_url relative to CLEVERAGENTS_HOME, not CWD
Ensure that when database_url is a relative path (like sqlite:///cleveragents.db), it resolves relative to CLEVERAGENTS_HOME instead of the current working directory. This fixes E2E test isolation where data from previous runs persisted across runs at CWD, causing UNIQUE constraint failures. Changes: - Added _resolve_database_urls model validator in Settings to rewrite relative SQLite paths to absolute paths under CLEVERAGENTS_HOME - Updated get_database_url() in container.py to use CLEVERAGENTS_HOME as base directory and create parent directories when CLEVERAGENTS_HOME is explicitly set - Updated _check_database() in system.py to walk up directory tree for writable ancestor check, handling cases where intermediate directories have not yet been created - Removed @tdd_expected_fail from TDD test (now passes genuinely) ISSUES CLOSED: #1024 |