Keep API imports consistent with file imports #108
A stored regex such as [ raises re.error here. TagRegex.regex has no regex validator, and the API only converts Django ValidationError into row errors, so this produces a 500 and stops later valid rows in a bulk request. It now also affects explicitly tagged requests, which previously skipped rule matching. Convert malformed-regex errors into ValidationError so the API can reject just the affected row.
<!-- ccr-overview-v2 -->
🟡 Changes recommended
A malformed stored regex can cause a 500 and halt valid rows in a bulk request, including explicitly tagged requests, instead of being handled as a row-level validation error.
<details open>
<summary><strong>1 open issue</strong></summary>
</details>
<details>
<summary><strong>What changed in this PR</strong></summary>
Aligns API entry creation with file imports by sharing regex-based inference, validation, and transactional saving.
Changes:
Tests and linters were not run.
| File | Description |
| ---- | ----------- |
| README.md | Documents asset overrides, regex inference, and transfer behavior. |
| gemcore/tests/test_views.py | Tests the query-count assertion helper. |
| gemcore/tests/test_parser.py | Covers deferred fees, transfers, rollback, and lookup reuse. |
| gemcore/tests/test_models.py | Tests regex prefetching and query-free resolution. |
| gemcore/tests/helpers.py | Adds a helper for detecting query-count growth. |
| gemcore/parser.py | Routes CSV imports through shared resolution and creation logic. |
| gemcore/models.py | Adds shared regex resolution and prefetching. |
| gemcore/forms.py | Centralizes transactional entry and counterpart creation. |
| gemapi/views.py | Eager-loads assets for entry responses. |
| gemapi/tests.py | Tests import parity, overrides, transfers, and query counts. |
| gemapi/serializers.py | Adds asset support, cached lookups, and shared entry creation. |
</details>
<sub>Review effort: Balanced</sub>
This is tracked in #110.
nessita
API imports now use the same regex rules as file imports.
Rules can assign tags and assets, and create transfer counterparts.
Explicit tags and assets override inferred values.
An entry and its transfer counterpart either both save or neither does.
Invalid rows do not stop other valid rows.
Shared lookups are reused within each batch.
A new test helper checks whether adding more items causes extra queries.
Added tests for these behaviors. You still need to run tests and linters.