{"record":{"id":"037e4c7d84664850","repo":"clockworklabs/SpacetimeDB","slug":"tried-to-read-n-byte-s-at-relative-offset-th","errorCode":null,"errorMessage":"Tried to read ${n} byte(s) at relative offset ${this.offset}, but only ${this.remaining} byte(s) remain","messagePattern":"Tried to read (.+?) byte\\(s\\) at relative offset (.+?), but only (.+?) byte\\(s\\) remain","errorType":"validation","errorClass":"RangeError","httpStatus":null,"severity":"error","filePath":"crates/bindings-typescript/src/lib/binary_reader.ts","lineNumber":43,"sourceCode":"    this.offset = 0;\n  }\n\n  reset(input: Uint8Array | DataView) {\n    this.view =\n      input instanceof DataView\n        ? input\n        : new DataView(input.buffer, input.byteOffset, input.byteLength);\n    this.offset = 0;\n  }\n\n  get remaining(): number {\n    return this.view.byteLength - this.offset;\n  }\n\n  /** Ensure we have at least `n` bytes left to read */\n  #ensure(n: number): void {\n    if (this.offset + n > this.view.byteLength) {\n      throw new RangeError(\n        `Tried to read ${n} byte(s) at relative offset ${this.offset}, but only ${this.remaining} byte(s) remain`\n      );\n    }\n  }\n\n  readUInt8Array(): Uint8Array {\n    const length = this.readU32();\n    this.#ensure(length);\n    // Return an owned copy, not a view over the reader's buffer. Decoded column\n    // values are handed to user code and may be retained, but the runtime reuses\n    // this buffer across table scans, so a view would be silently invalidated by\n    // the next iter()/filter(). Callers that only consume the bytes transiently\n    // (e.g. readString) can use readBytes directly to avoid this copy.\n    // https://github.com/clockworklabs/SpacetimeDB/issues/5490\n    return this.readBytes(length).slice();\n  }\n\n  readBool(): boolean {","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/bindings-typescript/src/lib/binary_reader.ts#L25-L61","documentation":"spacetime update list reads the CLI bin dir's current symlink to mark the active version. If the symlink target's final path component cannot be extracted (Path::file_name() returns None — e.g. the target is '..', '/', or ends in '..' — or is non-UTF8), the listing aborts with this error. It signals a malformed current symlink, typically left by an old or interrupted install (the surrounding comment is about migrating legacy symlink layouts).","triggerScenarios":"The <bin-dir>/current symlink points to '..', '/', or another path whose last component is not a version directory name, so current_version() returns Some(path) whose file_name() is None or invalid.","commonSituations":"Interrupted install/--use leaving a half-written symlink; manual edits to the install dir; leftovers from pre-#2680 layouts that have not yet been fixed by two successive upgrades (see the comment in list.rs).","solutions":["Inspect the symlink: ls -l <bin-dir>/current — a healthy target looks like <bin-dir>/<x.y.z>.","Repoint it by switching versions: spacetime update install <installed-version> --use (rewrites current via set_current_version).","If no version is installed, delete the broken current symlink and install fresh, then use --use.","If it regresses again after upgrading twice, report it — the updater is supposed to fix legacy symlinks after two upgrades."],"exampleFix":"# before\n$ ls -l ~/.spacetime/bin/current\ncurrent -> ..            # malformed; `spacetime update list` fails\n\n# after\n$ rm ~/.spacetime/bin/current\n$ spacetime update install 1.7.1 --use\n$ spacetime update list   # works, marks 1.7.1 current","handlingStrategy":"validation","validationCode":"# BIN_DIR = the CLI bin dir (contains per-version dirs and `current`)\ntarget=\"$(readlink \"$BIN_DIR/current\" 2>/dev/null)\"\ncase \"$(basename \"$target\")\" in\n  ''|'..') echo \"current symlink malformed: $target\";;\nesac","typeGuard":null,"tryCatchPattern":null,"preventionTips":["After every install/--use, run `spacetime update list` once to confirm the current marker resolves.","Never hand-edit the current symlink; let `install --use` write it.","Upgrade twice in a row after adopting a new release so legacy symlink fixups run (see list.rs comment)."],"tags":["spacetimedb","cli","filesystem","symlink","version-management"],"backgroundTag":"version-detection-failed","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}