Repository navigation
fix(api): validate bank ids on import and reserve the _ prefix - #5673
Merged
Merged
Conversation
- A whole-bank import created its target bank (the target_bank_id, or the archive manifest's source_bank_id) without validate_new_bank_id. The check now runs in import_bank_async for a bank that does not exist yet, which covers the HTTP restore, clone and the admin CLI import-bank. The HTTP submit also checks up front so the caller gets a 400, not a failed operation. - validate_new_bank_id also refuses a new id starting with `_`: a store-owned backend reserves that prefix for its own bookkeeping objects next to a bank's objects. Existing banks are not re-checked. Closes #5540
Fixes verify-generated-files: the alias description's new 'no leading underscore' rule was missing from the Go spec copy.
This was referenced Oct 20, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the two gaps left in #5540.
validate_new_bank_idalready guards bank create/ensure, clone and aliases.Gap 1: whole-bank import skipped the check
submit_bank_import_asyncandimport_bank_asynccreated the target bank (target_bank_id, or the archive manifest'ssource_bank_id) without callingvalidate_new_bank_id. A 300-byte id or one with a newline was accepted with a 202 and the bank was created.Fix:
import_bank_asyncnow callsvalidate_new_bank_idwhen the target bank does not exist yet. Every restore goes through this method: the HTTP import worker, clone, and the admin CLIimport-bank. Existing banks are still never re-checked. The check runs before the restore for bothinclude_bank_configbranches.submit_bank_import_asyncmakes the same call (one line) after its "already exists" check, so an HTTP caller gets a 400 at once instead of a failed background operation.Gap 2: reserve the
_prefixvalidate_new_bank_idnow refuses a new bank id that starts with_. A store-owned backend that keeps its own bookkeeping objects (_index,_meta, ...) next to a bank's objects needs a part of the name space that no bank can take. Without this rule, each such backend has to invent its own escaping. Existing banks are not affected. No code or test in this repo creates a bank whose id starts with_(I searched).The alias request's field description (and the OpenAPI spec and generated clients that copy it) now lists the new rule.
The 192-byte cap is unchanged.
Tests
test_document_transfer.py::test_bank_import_refuses_an_invalid_new_bank_id, run for a too-long id, an id with a newline, and a_-prefixed id. It checks that bothsubmit_bank_import_async(HTTP) andimport_bank_async(worker and CLI) raise a 400 and that no bank is created.test_ensure_bank_exists_optimization.py::test_invalid_new_bank_id_is_rejected_before_insertgets a newunderscore-prefixcase: a direct create with a_-prefixed id is a 400 and inserts no row.Closes #5540