Skip to content

Type the Docker build-info payload as a BuildInfo TypedDict (P311-02) - #4106

Merged
Roman Lutz (romanlutz) merged 3 commits into
microsoft:mainfrom
Sainath-Reddy7:p311-02/buildinfo-typeddict
Nov 9, 2026
Merged

Roman Lutz (romanlutz) merged 3 commits into
microsoft:mainfrom
Sainath-Reddy7:p311-02/buildinfo-typeddict

Conversation

@Sainath-Reddy7

Copy link
Copy Markdown
Contributor

Description

Implements the P311-02 focused case from #3166 (reserved here, due 2026-11-12): the Docker build-info payload in pyrit/backend/routes/version.py.

_load_build_info typed the parsed /app/build_info.json as dict[str, Any], and the route read four known keys (source, commit, modified, display) with absent-tolerant .get semantics (display falls back to the package version). This introduces a BuildInfo TypedDict with NotRequired members, mirroring RawAnalyticsProfile's style, so absent keys stay distinguishable from nullable values and the key names are checked rather than stringly typed. No Pydantic runtime validation is introduced or replaced.

Unchanged: the JSON load, the warning-path fallback, and every route behavior.

Tests

  • New test_build_info_keys_are_not_required pins the TypedDict's exact key set and that an empty payload is valid.
  • New test_get_version_build_info_absent_display_falls_back proves a file without display falls back to the package version (the absent-vs-null distinction this item asks for).
  • Existing build-info tests cover the loaded and failure paths.
  • TestVersionRoutes: 6/6 pass locally; ty check: all checks passed; ruff check/format clean.

Checklist

AI assistance disclosure: prepared with an AI coding agent (GLM-5.3) under my direction; I reviewed each line, ran the suite and type checks locally, and stand behind the change.

_load_build_info returned dict[str, Any] and the route read four known
keys with stringly-typed .get calls. BuildInfo declares source, commit,
modified and display as NotRequired, mirroring RawAnalyticsProfile, so
absent keys stay distinguishable from nullable values and key names are
checked. Runtime behavior, the JSON load and the warning-path fallback
are unchanged; tests pin the key set and the absent-display fallback to
the package version.
Copilot AI balanced review requested due to automatic review settings November 9, 2026 12:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Nov 9, 2026
Merged via the queue into microsoft:main with commit 7e0f11c Nov 9, 2026
57 of 59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants