Skip to content
Astera Technology

Why did a spreadsheet name import as the number 1?

Resolve a shared-string index through its supplied string table.

Download complete case notes and answer keys ↓

Read the source and its declared rule

This extracted shared-string cell stores index 1 into [Ada, Bo]. Indices are zero-based, so its text is Bo. The original import contract requires an integer index inside the supplied table; the example works on extracted records rather than parsing an XLSX package.

Filled synthetic input
RecordInput JSON
Base input{"index":1,"shared":["Ada","Bo"]}
Download editable CSV ↓

Compare the actual paths

The bad path stores the reference itself as text 1. Correct output stores Bo; losing the shared table prevents resolving the source name.

Misleading and corrected outputs
PathOutput JSON
Misleading path{"accepted":true,"text":"1"}
Corrected path{"accepted":true,"text":"Bo"}
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){
    if(!corrected)return {accepted:true,text:String(i.index)};
    if(!Number.isInteger(i.index)||i.index<0||i.index>=i.shared.length)return {accepted:false,error:'shared-string-reference'};
    return {accepted:true,text:i.shared[i.index]};
  };
const cases=[{"label":"misleading base","input":{"index":1,"shared":["Ada","Bo"]},"expected":{"accepted":true,"text":"1"},"corrected":false},{"label":"corrected base","input":{"index":1,"shared":["Ada","Bo"]},"expected":{"accepted":true,"text":"Bo"},"corrected":true},{"label":"first shared string","input":{"index":0,"shared":["Ada","Bo"]},"expected":{"accepted":true,"text":"Ada"},"corrected":true},{"label":"out of bounds reference","input":{"index":2,"shared":["Ada","Bo"]},"expected":{"accepted":false,"error":"shared-string-reference"},"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

Index 0 resolves Ada. Index 2 is outside this two-entry table and must be held.

Editable boundary records and expected outputs
CaseInput JSONExpected output JSON
First shared-string position{"index":0,"shared":["Ada","Bo"]}{"accepted":true,"text":"Ada"}
Reference beyond table{"index":2,"shared":["Ada","Bo"]}{"accepted":false,"error":"shared-string-reference"}
Download editable CSV ↓

What text belongs to index 1 here?

Show the worked answer

Bo. The value 1 is a position in the supplied shared-string table, not the name.

Related resources