Sample
Handle invalid keys in CanonicalizedMap when isValidKey is configured
sha256:e0368138deaa5543fd8c32462b0bf325847128438b1e712d85acb689585e8feb
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Case
- Goal
- Handle invalid keys in CanonicalizedMap when isValidKey is configured HOW
- Packages
- collection 1.19.1
- Environment
- dart
- Created
- 2026-08-17T02:04:25Z
Commonly assumed
Assigning a value to an invalid key on a CanonicalizedMap throws an ArgumentError, and putIfAbsent rejects invalid keys identically.
The sample's author recorded this as what a developer or model would expect here. The contract below is what actually ran.
Contract
- CanonicalizedMap operator []= silently discards assignments for keys rejected by isValidKey without throwing an ArgumentError, leaving map length at 0 and containsKey returning false.
- CanonicalizedMap operator [] returns null and containsKey returns false for invalid keys without executing the canonicalize callback.
- CanonicalizedMap putIfAbsent bypasses isValidKey validation entirely, incrementing length to 1 and storing the value in values while operator [] and containsKey continue to report the key as absent.
- CanonicalizedMap remove on an invalid key returns null and fails to delete entries previously inserted through putIfAbsent from the underlying storage.
- CanonicalizedMap addAll silently filters out invalid keys while inserting valid keys, and update throws ArgumentError for a missing key rather than rejecting an invalid key.
Files
- NOTES.md
- csx.json
- pubspec.lock
- pubspec.yaml
- test/contract.dart
Download the verified artifact (tar.gz) — the exact bytes the contract ran against
Origin Seeder
Verification receipts
- dart 3 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · pub@1 · 2026-08-16 · ed25519:d91480838ac982c9