fix(crud): strip view-only join columns from order_by_li to prevent ambiguous account_id in WHERE
Sorting by join-derived columns (e.g. event_presenter_family_name on v_event_file) caused MariaDB to expand the view's JOIN inline, making the unqualified account_id clause from sql_and_qry_part ambiguous — resulting in a 400 SQL error. filter_order_by now accepts raw_table_name and validates ORDER BY columns against the physical table only; join-only columns are silently stripped. Also switches filter_order_by off the global db connection to engine.connect() context managers. Updated all four call sites in api_crud_v3.py and api_crud_v3_nested.py. Docs: add order_by_li raw-table limitation and direct download link patterns to GUIDE__AE_API_V3_for_Frontend.md; record fix in TODO__Agents.md. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
- [x] **[P4] Expose `pool_size` / `max_overflow` as env vars** — `create_ae_engine()` calls `settings.DB.get('pool_size', 10)` but `settings.DB` property doesn't include those keys, so they're always hardcoded 10/20. Add `AE_DB_POOL_SIZE` / `AE_DB_POOL_MAX_OVERFLOW` to `config.py`.
|
||||
|
||||
## 📋 Feature Tasks
|
||||
- [x] **`order_by_li` view-join ambiguity fix (June 2026):** Using view-only join columns (e.g. `event_presenter_family_name` from `v_event_file`) in `order_by_li` caused MariaDB error "Unknown column 'account_id' in WHERE" (HTTP 400). Root cause: `filter_order_by` validated columns against the view — which passes for join-derived fields — and `sql_and_qry_part` generates an unqualified `account_id =` clause that becomes ambiguous when MariaDB expands the view's JOIN inline. Fix: `filter_order_by` now accepts `raw_table_name` and validates ORDER BY columns against the physical table only. Join-only view columns are silently stripped. Updated all three call sites in `api_crud_v3.py` (×2) and `api_crud_v3_nested.py` (×2). **Follow-up (lower priority):** qualify `account_id` in `sql_and_qry_part` to fix the root ambiguity for any future JOIN-capable views.
|
||||
- [x] **Core Isolation:** Harden `apply_forced_account_filter` to Fail-Closed.
|
||||
- [x] **IDAA Baseline:** Remove `public_read` from Event, CMS, and Archive objects.
|
||||
- [x] **Detailed Feedback:** Implement descriptive 403 Forbidden reasons.
|
||||
|
||||
Reference in New Issue
Block a user