Skip to content
Astera Technology

Why did an import report success after silently skipping a rejected row?

Record actual constraint failures before releasing the staged batch.

Download complete case notes and answer keys ↓

Read the source and its declared rule

The original batch may stage individually valid rows, but release requires every supplied row to have an accepted disposition. A2, B−1, C3 uses NOT NULL and a positive quantity CHECK. OR IGNORE skips B without throwing; corrected ordinary inserts capture B’s actual CHECK275 and hold release.

Filled synthetic input
RecordInput JSON
Base input{"records":[{"id":"A","quantity":2},{"id":"B","quantity":-1},{"id":"C","quantity":3}]}
Download editable CSV ↓

Compare the actual paths

A andC remain staged in both paths. The difference is a retained B rejection rather than a false claim that all three inputs succeeded.

Misleading and corrected outputs
PathOutput JSON
Misleading path{"released":true,"errors":[],"target":[{"id":"A","quantity":2},{"id":"C","quantity":3}]}
Corrected path{"released":false,"errors":[{"source":"B","code":275}],"target":[{"id":"A","quantity":2},{"id":"C","quantity":3}]}
Download editable CSV ↓
Local Node.js program: 22.23.3 or 24.14.1
import {DatabaseSync} from 'node:sqlite';
import {TextDecoder} from 'node:util';
import {inflateSync} from 'node:zlib';
import {posix} from 'node:path';
import {createHash} from 'node:crypto';
const rows=(db,sql)=>db.prepare(sql).all().map(r=>({...r}));
const failed=(action)=>{try{action();return null;}catch(e){return {code:e.errcode??e.code??e.name};}};

import assert from 'node:assert/strict';
const run=function run(i,corrected=true){
    const db=new DatabaseSync(':memory:');try{db.exec('CREATE TABLE target(id TEXT PRIMARY KEY,quantity INTEGER NOT NULL CHECK(quantity>0));');const errors=[];
      for(const r of i.records){const error=failed(()=>db.prepare('INSERT '+(corrected?'':'OR IGNORE ')+'INTO target VALUES(?,?)').run(r.id,r.quantity));if(error)errors.push({source:r.id,code:error.code});}
      return {released:errors.length===0,errors,target:rows(db,'SELECT * FROM target ORDER BY id')};
    }finally{db.close();}
  };
const cases=[{"label":"misleading base","input":{"records":[{"id":"A","quantity":2},{"id":"B","quantity":-1},{"id":"C","quantity":3}]},"expected":{"released":true,"errors":[],"target":[{"id":"A","quantity":2},{"id":"C","quantity":3}]},"corrected":false},{"label":"corrected base","input":{"records":[{"id":"A","quantity":2},{"id":"B","quantity":-1},{"id":"C","quantity":3}]},"expected":{"released":false,"errors":[{"source":"B","code":275}],"target":[{"id":"A","quantity":2},{"id":"C","quantity":3}]},"corrected":true},{"label":"all valid writes","input":{"records":[{"id":"A","quantity":2}]},"expected":{"released":true,"errors":[],"target":[{"id":"A","quantity":2}]},"corrected":true},{"label":"empty permitted input batch","input":{"records":[]},"expected":{"released":true,"errors":[],"target":[]},"corrected":true},{"label":"missing quantity is retained as rejection","input":{"records":[{"id":"A","quantity":2},{"id":"B","quantity":null}]},"expected":{"released":false,"errors":[{"source":"B","code":1299}],"target":[{"id":"A","quantity":2}]},"corrected":true}];
for(const test of cases){
  const actual=run(test.input,test.corrected);
  assert.deepEqual(actual,test.expected,test.label);
  console.log(test.label,actual);
}
Download runnable example ↓

Check boundaries before the next load

All-valid A accepts. The explicitly permitted empty batch has no rejected inputs. Missing B quantity fails NOT NULL1299, retains valid staged A and holds release.

Editable boundary records and expected outputs
CaseInput JSONExpected output JSON
All valid input rows{"records":[{"id":"A","quantity":2}]}{"released":true,"errors":[],"target":[{"id":"A","quantity":2}]}
Permitted empty batch{"records":[]}{"released":true,"errors":[],"target":[]}
Missing quantity retained as rejection{"records":[{"id":"A","quantity":2},{"id":"B","quantity":null}]}{"released":false,"errors":[{"source":"B","code":1299}],"target":[{"id":"A","quantity":2}]}
Download editable CSV ↓

Do two stored rows prove the three-input batch succeeded?

Show the worked answer

No. B was skipped in the misleading path. Retain its code 275 disposition and hold release pending correction.

Related resources