fix(assets): skip validation for existing assets in ensure_assets#658
Merged
afadil merged 2 commits intoafadil:mainfrom Mar 3, 2026
Merged
Conversation
create_batch validates every NewAsset before INSERT OR IGNORE, including specs for assets that already exist in the DB. A UUID-only AssetSpec has instrument_symbol: None, which fails the MARKET-pricing validation even though the asset would be skipped by the INSERT OR IGNORE. Filter out specs whose IDs are already in existing_ids before building NewAsset values, so validation only runs for assets actually being created.
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.
Description
ensure_assetspasses all specs tocreate_batch, including ones for assets that already exist in the DB.create_batchvalidates everyNewAssetbefore doingINSERT OR IGNORE, so a UUID-onlyAssetSpec(e.g.symbol: { id: <uuid> }with no symbol string) fails the MARKET-pricing validation withInvalid input: Investments with MARKET pricing require an instrument_symbol— even though the asset exists and would be skipped by the INSERT OR IGNORE.Fix: filter out specs whose IDs are already in
existing_idsbefore buildingNewAssetvalues, so validation only runs for assets actually being created.Checklist
Contributor License Agreement.
By submitting this PR, I agree to the
CLA.