SoccerDream AI 首页  ›  GEO 内容中心  ›  近期更新(自动生成)

7.7% of this "JSON" column is not JSON, and the other 92% has 511 shapes

A text column named full_analysis is the cheapest schema you will ever ship. There is no migration to write, no table re…

本页内容由人工智能生成,仅供参考

A text column named full_analysis is the cheapest schema you will ever ship. There is no migration to write, no table rewrite to schedule. The writer just dumps a string, the reader just calls json.loads, and for as long as both sides are the same deploy everything works.

Then one day the reader throws JSONDecodeError, and the answer is not "fix the parser": two machines have been writing to the same field with different ideas of what a payload is, and nobody was counting.

This is an audit of one such column in a production football-prediction system: ai_predictions.full_analysis, in PostgreSQL, holding 52,273 non-null payloads written between 2026-06-21 and 2026-12-04. Every number below comes from a single REPEATABLE READ snapshot, so the counts are internally consistent.

What the column actually contains

QuantityValue
Rows in ai_predictions52,377
Rows with a non-null full_analysis52,273
Declared typetext (not jsonb)
Payloads that parse into an object48,269 (92.34%)
Payloads that do not parse at all4,004 (7.66%)
Distinct top-level keys across parsed rows305
Distinct key sets (i.e. schemas) across parsed rows511

7.66% is four thousand rows dropped silently by every json.loads consumer — except Exception: pass is what everyone writes — and 511 key sets means the column has a distribution of schemas, not a schema.

Three ways a payload stops being JSON

The failures are not one bug. Classified by first character and first token:

Failure classRowsShare of failures
Markdown-fenced (``` `json `` … `` ` ```)2,11152.7%
Plain prose (Chinese analysis text)1,88447.1%
Truncated / malformed JSON80.2%
Empty (whitespace only)1—

The fenced class is the interesting one: the model produced JSON, then wrapped it in a markdown fence, because a chat interface trained it to. The payload is valid one layer down — strip the fence and it recovers; do not, and half the hard failures vanish into a formatting convention.

The prose class cannot be recovered by any parser. Those 1,884 rows are paragraphs of Chinese analysis with no object at all — a different prompt, or a fallback that stored the raw completion when parsing failed upstream.

Here is the census, as run:

import json, collections, psycopg2

cur = psycopg2.connect("postgresql://.../soccerdream").cursor()
cur.execute("select full_analysis from ai_predictions where full_analysis is not null")

cls, shapes, keys = collections.Counter(), collections.Counter(), collections.Counter()
for (txt,) in cur:
    s = txt.strip()
    try:
        doc = json.loads(s)
    except json.JSONDecodeError:
        kind = ("blank" if not s else
                "fenced" if s.startswith("```") else
                "broken" if s[0] in "{[" else "prose")
        cls[kind] += 1
        continue
    shapes[frozenset(doc)] += 1
    keys.update(doc)

print(sum(cls.values()), cls.most_common(), len(shapes), len(keys))
4004 [('fenced', 2111), ('prose', 1884), ('broken', 8), ('blank', 1)] 511 305

The same predicate in SQL:

select date_trunc('month', created_at)::date as month,
       count(*) as rows,
       count(*) filter (where btrim(full_analysis) like '```%') as fenced,
       count(*) filter (where left(btrim(full_analysis), 1) <> '{') as not_object
from ai_predictions
where full_analysis is not null
group by 1 order by 1;

The month with zero failures proves it is a writer problem

MonthPayloadsUnparseableRateFenced share of failures
2026-062,73551418.8%82.7%
2026-072,55800.0%—
2026-081393223.0%0.0%
2026-099,7578829.0%27.2%
2026-1021,8869804.5%44.6%
2026-1114,5411,2718.7%58.6%
2026-1265732549.5%81.2%

If the cause were the model, the rate would track model quality. Instead it tracks who was writing that month: July's pipeline parsed before insert, June's did not, September's stored prose, December's stored whatever came back, fence included. The column never had a contract, so each deploy renegotiated it — and 2,558 consecutive successes did not stop the next writer from breaking the field.

511 shapes, 305 keys, and five keys that carry the load

Grouped by key set, the distribution is a long tail with a few dominant modes:

Key setRowsShare
asian_handicap, goal_line, prediction10,41121.6%
asian_handicap, confidence, direction, goal_line, reasoning, score_prediction8,49517.6%
the same six plus _ec, _dir_source4,1748.6%

Five keys appear in more than half the parsed rows: asian_handicap (97.93%), goal_line (93.07%), confidence (55.80%), direction (55.76%), reasoning (51.93%). Everything else is optional. The median payload carries six keys; the range runs from zero (2 rows) to nineteen (3 rows).

Distinct key sets per month tell the churn story better than the total:

2026-06: 6   2026-07: 14   2026-08: 3   2026-09: 129
2026-10: 255 2026-11: 225  2026-12: 24

Six shapes in June, three in August, then 129 and 255 as the pipeline started attaching shadow diagnostics. Two hundred and fifty-five schemas in a single month is not a schema with optional fields — it is a debugging session that shipped.

Type drift: the same key, two different things

Within the parsed rows, these keys changed type:

Keyintstrdictlistfloat
confidence26,9321——1
reasoning—25,06321—
score_prediction—20,1871——
analysis—1,8627,377——
asian_handicap—1,85945,412——

The singletons are the dangerous part. doc["confidence"] > 5 works 26,932 times and raises on the row where the same field arrived as the string "7"; doc["analysis"]["conclusion"] works for 7,377 rows and raises on 1,862 where analysis is a paragraph. Each failure is a silent skip in a batch job, and none shows up in a row count.

asian_handicap is the clearest case: an object in 45,412 rows and a string in 1,859, and all 1,859 strings are in June — the same month that contributed the keys over_under and score and nothing else. A shape change that coincides exactly with a calendar month is a deploy, not noise. Even the names drift: asian_hk-floor in 287 rows, asian_hk_floor in 8, and none of it documented inside the database.

The same number stored twice, disagreeing a quarter of the time

confidence exists as an integer column and as a key inside the payload. Where both are present, 26,933 rows, they agree on 20,082 — 74.56%. On 6,851 rows they disagree, and the largest disagreement is 83 points. The column is a 1–10 scale; the key is sometimes a percentage. A consumer reading the wrong one is off by an order of magnitude and has no way to notice. A schemaless column does not remove the schema — it moves it into every reader, where each reader gets a slightly different version and none can be tested.

A typed column does not fix it

The table also has three jsonb columns, which cannot hold invalid JSON. That guarantee is real, and much narrower than it looks:

ColumnRowsShape
ah_v5_factors23,804 (45.4% of table)object 23,796, array 8, 4 distinct keys
conflict_flags52,377object 31,222, array 21,155
injected_rule_ids27,674array 27,674 (all of them)

conflict_flags is populated on every row and is an object on 31,222 of them and an array on 21,155. jsonb promised syntax; it never promised shape, and shape is what the reader needs. The only column with a stable contract is injected_rule_ids, and its stability is an accident: it was born in August (112 rows), later than the shape wars.

The envelope, and one parser instead of N

The repair is not a rewrite. It is a second table with a contract, plus one function every writer must go through:

create table prediction_payloads (
  prediction_id  bigint primary key references ai_predictions(id),
  schema_version smallint not null,
  body           jsonb    not null,
  body_sha256    bytea    not null,
  written_at     timestamptz not null default now(),
  constraint body_object  check (jsonb_typeof(body) = 'object'),
  constraint body_version check (body ? 'schema_version'),
  constraint body_core    check (body ? 'goal_line' and body ? 'confidence')
);

Three properties are enforced by the database rather than by convention: the body is an object, it carries its own version, and the fields every consumer needs are present. A writer that breaks any of them fails at insert time — in the writer's logs, not in a job three days later.

The corresponding read path is one function, and it is deliberately strict about what it will accept:

def parse_payload(raw: str | None) -> dict | None:
    if raw is None:
        return None
    s = raw.strip()
    if s.startswith("```"):                       # fenced completion
        s = s.split("\n", 1)[1] if "\n" in s else ""
        s = s.rsplit("```", 1)[0]
    try:
        doc = json.loads(s)
    except json.JSONDecodeError:
        return None
    return doc if isinstance(doc, dict) else None

The fenced branch recovers 2,111 rows; the None branch makes the other 1,893 visible in a counter instead of a traceback. Backfill into the new table, never update the old column in place — the old column is the evidence, and rewriting it destroys the ability to prove what happened.

What the rot cost, and how to keep the count

Two costs are already visible. First, 746 payload groups are byte-identical duplicates covering 3,815 rows, one payload repeated 122 times — a reader that aggregates "analyses" without deduplicating counts one document 122 times. Second, 12 rows contain a full_analysis key inside full_analysis: wrapped twice, and one inner value is a revision transcript rather than JSON.

The failure is also distributed, not localised: 796 of 4,043 models (19.7%) produced at least one unparseable row and the five worst account for only 4.5% of failures. No model to retire, no single writer to blame — this is what a missing contract looks like after six months.

So the metric to keep is not the total count of parse failures, which only grows — it is the rate, per writer and per day, with a threshold that fails the publish instead of logging a warning: above 0.5% unparseable, the batch does not go out. The 0.0% month was not luck, it was a writer that parsed before insert. Make that the only path and the other 511 shapes stop being possible.

Analytics and research content. Not betting advice. 18+

本内容仅供数据分析与操作参考,不构成任何决策建议。

风险提示:足球比赛结果具有内在不确定性,任何数据分析工具都无法消除这种随机性。本页内容仅供数据操作与参考,不构成任何决策建议或收益承诺。请理性看待体育赛事,远离任何形式的非法决策活动。
看完方法论,直接看它怎么用在今天的比赛上

SoccerDream AI 每场给出胜平负概率分布、总进球区间与置信度, 赛后自动复盘、命中记录公开可查。注册后可查看全部 AI 模型推演与已结算战绩。

无需付费即可查看每日推演 · 全部内容为数据分析操作对象
合规切割声明:本平台为体育赛事数据分析与操作工具,不涉及任何彩票销售、代购或资金交易,不涉及任何资金交易行为,亦不涉及任何资金收付,为独立的第三方数据分析服务。全部内容仅供操作与参考。请遵守所在地法律法规,理性对待。
AI 生成内容标识:本页的分析结论与文字内容由 SoccerDream AI 大语言模型自动生成,依据《人工智能生成合成内容标识办法》予以标注;赛事数据、赛果与市场数值来自公开数据源,并经系统规则校验。内容仅供操作参考,不构成任何建议。