← Back to Pull requests

Reject mismatched scalar values in set_message_fields #42

Open
unknown opened this pull request with 189 lines diff across 2 files
View on GitHub
unknown unknown commented on Sep 14, 2026 23:11 UTC
Author

Description

set_message_fields() currently falls back to calling the target Python type as a constructor when the supplied value has a different type. For primitive scalar fields, this can silently change the value instead of raising the documented TypeError, for example:

  • bool("false") becomes True

  • bool(-1) becomes True

  • int(1.5) becomes 1

  • str(True) becomes "True"
  • This change rejects unsafe cross-type coercions while preserving compatible scalar inputs that previously worked.

    Compatible inputs include:

  • exact primitive types

  • Python subclasses of the corresponding primitive type

  • matching NumPy scalar types such as numpy.float64 -> float, numpy.int64 -> int, and numpy.bool_ -> bool

  • integer and NumPy-integer values for float fields, preserving the existing YAML / ROS 2 CLI widening behavior
  • Boolean values are explicitly excluded from integer and float fields even though Python treats bool as a subclass of int.

    Container, nested-message, NumPy array, buffer, Header: auto, and Time: now handling are unchanged.

    Fixes #41

    Testing

  • test/rosidl_runtime_py/test_set_message.py: 15 passed

  • full package test directory: 57 passed

  • flake8 / pep257 / copyright / xmllint checks passed

  • git diff --check passed
  • Local testing required a temporary PYTHONPATH stub for the missing rosidl_buffer package in the WSL environment; the same import failure reproduces on a clean checkout and no environment workaround is included in this change.

    Diff: 189 lines (+141 / -48) across 2 files Reviewer: dlanov Review duration: 72634m
    All Vouch review confidence checks passed
    Residual risk 0.25 = Change Risk (0.43) × (1 − Review Confidence (0.41)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 189 lines diff across 2 files
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    40%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.314
    Real PR Conversation Timeline
    1 comments
    "Review active on #42"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 40.9% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.9% (MEDIUM) · Higher = larger blast radius
    42.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 40.9% · Lower = rushed or shallow review
    40.9%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 25.3% · Safe to merge
    25.3%