Skip to content

[BUG]: List[Dict[...]] exports clip_under_threshold=false, and its items are mistyped as string #333

Closed

Description

@vawsgit

Problem

Two defects stack on the List[Dict[...]] JSON-Schema export path. Neither corrupts scoring today, because the first one masks the second — but fixing the first without the second silently mis-sets clipping.

Measured on 35e6de1 (PR #316) vs dev:

class M(StructuredModel):
    ld: List[Dict[str, str]] = ComparableField(threshold=0.9)

M.to_json_schema()["properties"]["ld"]
dev PR #316
items {"type": "string"} {"type": "string"}
x-aws-stickler-clip-under-threshold true false
re-imported annotation Optional[List[str]] Optional[List[str]]

1. items is mistyped as string (pre-existing, unfiled)

A List[Dict[str, str]] field exports items: {"type": "string"}, so to_json_schema() → from_json_schema() returns Optional[List[str]]. The round-tripped model scores a different shape than the original. Present on dev; not introduced by #316.

2. clip_under_threshold: false is now written into the export

PR #316 admitted _is_list_of_mappings into _install_mapping_comparators (structured_model.py:455) to close a real Dict vs List[Dict] scoring divergence — the right fix. But the clip amendment mutates the FieldInfo the exporter reads, so the exported schema now carries a clip_under_threshold the user never wrote.

Why this matters later, not now

Because of defect 1 the re-imported field is already the wrong type, so no working measurement path changes and #316 was approved on that basis. Once items is exported correctly, defect 2 becomes live: the shape comes back as a primitive list with clipping off, which is wrong for a primitive list and will keep partial credit that should have been zeroed.

Suggested fix

Fix both together, or fix 2 first. The clip amendment should apply to the in-memory field (where it is correct and needed) without becoming part of the exported schema for a shape whose annotation the exporter cannot represent yet.

The comment at structured_model.py:477-481 declines to move the comparator substitution precisely to avoid changing this shape's exported schema — the clip amendment should follow the same rule.

Found during review of #316.

Activity

  1. added
    bug
    on Sep 10, 2026
  2. added this to the 1.0.1 (Minor) milestone on Oct 15, 2026
  3. moved this from Backlog to In progress in Stickler Kanbanon Oct 16, 2026
  4. added a commit that references this issue on Oct 29, 2026
  5. moved this from In progress to Done in Stickler Kanbanon Oct 30, 2026
  6. added a commit that references this issue on Nov 20, 2026
    5abd7b9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions