Empty JSON array ([]) as a lookup-table reference file causes a confusing IntegrityError in load_table()
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 84/100
Línea de trabajo
Comienza en astrodbkit.astrodb.Database.load_table(), donde los datos de json.load() se pasan a insert().values(data). Reproduce el comportamiento con un archivo de tabla de referencia de nivel superior [] y sigue build_db_from_json(); se considera terminado cuando el archivo vacío se trata como no-op y no se produce ninguna fila con valores predeterminados ni un IntegrityError.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Where: astrodbkit.astrodb.Database.load_table() does conn.execute(self.metadata.tables[table].insert().values(data)) where data comes straight from json.load(). If the JSON file's top-level array is empty ([]), SQLAlchemy's insert().values([]) is interpreted as "insert one row using column defaults" (a known SQLAlchemy quirk: an empty list to a multi-row .values() isn't a no-op), not "insert nothing."
What happened: After emptying Publications.json, SourceTypeList.json, and ParameterList.json to [] (clearing stale template-example placeholder rows before real data existed), build_db_from_json() failed with sqlite3.IntegrityError: NOT NULL constraint failed: Publications.reference — a single default-valued row was attempted, which violated the non-nullable reference column. The error message gives no hint that the root cause was an empty-array JSON file rather than a real data problem.
Workaround: Deleted the three now-empty JSON files entirely instead of leaving them as [] — load_table()'s existing if os.path.exists(filename): guard cleanly skips a missing file (with an optional verbose "not found" message), which is the actual correct way to represent "no data yet" for a reference table.
Suggested change: Database.load_table() should special-case if not data: return before calling insert().values(data), so an empty-array reference file is a documented no-op instead of an inserted row of column defaults that then trips downstream NOT NULL constraints.
Cross-filed: Also filed against the astrodb-bot skills repo as astrodbtoolkit/astrodb-bot#99, which documents the same gotcha from the skill-user workaround side; this issue is for the actual astrodbkit fix.
Reported from a gotchas.md log filed by a skill user (2026-08-28).
- Lenguaje dominante
- Python
- Estrellas
- 12
- Forks
- 5
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de astrodbtoolkit/AstrodbKit
-
Nulls and load_table Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
astrodbtoolkit/AstrodbKit#109 ·
-
Remove `wcs1d_multispec` reader. Abierto
astrodbtoolkit/AstrodbKit#105 · 1 asignado ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
astrodbtoolkit/AstrodbKit#104 ·
-
bug
astrodbtoolkit/AstrodbKit#103 · 1 asignado ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 42/100
astrodbtoolkit/AstrodbKit#101 · 1 comentario ·
Todos los issues de astrodbtoolkit/AstrodbKit
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
xinnan-tech/xiaozhi-fde-talk#263 ·
-
rules
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
huggingface/Repo2RLEnv#163 · 1 comentario ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 95/100
huggingface/sentence-transformers#4074 ·
-
comp/dashboard invalid P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
NousResearch/hermes-agent#121143 ·