Skip to content

fix: restore BaseMessage.data default, validated - #273

Merged
pontino merged 1 commit into
mainfrom
fix/basemessage-validated-default
Sep 7, 2026
Merged

pontino merged 1 commit into
mainfrom
fix/basemessage-validated-default

Conversation

@pontino

@pontino pontino commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Undoes the breaking part of #259 while keeping its fix.

#259 made BaseMessage.data required because pydantic does not validate defaults, so BaseMessage[Order] accepted an envelope with no data and handed the handler a plain {}. Pydantic's validate_default=True covers exactly that case: the {} default is validated against the bound type, fails for BaseMessage[Order] (ValidationError, which typed subscriptions already treat as "not ours") and passes for the untyped base.

Case 0.4.0 this PR
BaseMessage(source, type) no data ValidationError accepted, data == {}
BaseMessage[Order] no data ValidationError ValidationError
BaseMessage[Order] wrong shape ValidationError ValidationError

Message is unchanged. New test test_untyped_base_message_defaults_to_empty_dict fails on main and passes here; the #259 tests for the typed cases still pass.

Verification (local, live Redis + Redpanda, Python 3.12): 109 passed, 0 skipped; mypy clean in the CI configuration; ruff clean.

0.4.0 made data required to stop typed subclasses from silently accepting a
missing payload (pydantic does not validate defaults). validate_default=True
gives the same protection: the {} default fails validation for
BaseMessage[Order] and passes for the untyped base, so
BaseMessage(source=..., type=...) works again.
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

QualOps Code Quality Analysis

Status: ⚠️ WARNINGS - Medium severity issues found

Summary

  • Total Issues: 3
  • Critical: 0 🔴
  • High: 0 🟠
  • Medium: 1 🟡
  • Low: 2 🟢
  • Files Analyzed: 3

🟡 Medium Issues (1)

  • sdk/eggai/schemas.py:77 - bug
    Adding validate_default=True to BaseMessage.data is a breaking change for existing consumers that instantiate BaseMessage or any typed subclass without providing data.

📊 Full Report

View detailed report


Powered by QualOps

@pontino
pontino merged commit 3970285 into main Sep 7, 2026
13 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.

1 participant