TypeScript insert.text fails on an extracted event_time out of range where Python drops the time

Aperta Adatta ai principianti
#363 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
node.js, typescript
Ambito
backend, databases

Direzione di ricerca

Leggi lenientTime in typescript/src/extraction/extractor.ts e confrontane il comportamento con _lenient_event_time di Python e con la correzione della scrittura diretta nell’issue #79. Verifica come validateFacts gestisce le date analizzate fuori intervallo, quindi aggiungi test per i due esempi di offset nei test TypeScript pertinenti. Il lavoro è completato quando insert.text memorizza la relazione senza un orario dell’evento e inserisce comunque il resto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

approved-for-pr area: extraction area: parity bug effort: S P2

What happens

An extracted event_time whose offset moves the UTC instant outside years 1 to 9999, such as 9999-12-31T23:59:59-14:00 or 0001-01-01T00:00:00+14:00, fails the whole TypeScript insert.text with invalid_argument. Python's lenient parser treats the same text as unparseable, stores the relation without a time, and inserts the rest.

Reproduce

On main (5a277c9), embedded Kuzu:

import { mkdtempSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { KuzuStore, SelfGraph } from "@hydradb/selfgraph";

async function run(name: string, replies: Record<string, unknown[]>) {
  const llm = {
    async generate({ output }: { output: { shape: Record<string, unknown> } }) {
      const kind = Object.keys(output.shape)[0]!;
      return { [kind]: replies[kind] ?? [] };
    },
  };
  const g = new SelfGraph(new KuzuStore(join(mkdtempSync(join(tmpdir(), "sg-")), "g.kuzu")), { llm });
  try {
    const r = await g.insert.text("Ann works at Acme.");
    console.log(name, "ok", r.entities.map((e) => e.id));
  } catch (e) {
    console.log(name, (e as { code?: string }).code, (e as Error).message);
  } finally {
    await g.close();
  }
}

await run("out of range", {
  relations: [{ from_name: "Ann", type: "KNOWS", to_name: "Bob", event_time: "9999-12-31T23:59:59-14:00" }],
});

Prints out of range invalid_argument relation event_time is outside the representable datetime range. Python stores thing:ann -KNOWS-> thing:bob with event_time null.

Cause

lenientTime in typescript/src/extraction/extractor.ts returns the parsed Date without the range check; validateFacts then rejects it for the whole batch. Python's _lenient_event_time returns None because parse_time raises ValidationError there. #79 fixed the direct write path, not this one.

Lingua principale
TypeScript
Stelle
173
Fork
58
Merge medio
6h
PR unite (30g)
120

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di hydra-db/selfgraph

Tutte le issue di hydra-db/selfgraph

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.