Skip to content

Conversation

@dmarek-flex
Copy link
Contributor

@dmarek-flex dmarek-flex commented Feb 11, 2026

Addresses FXC-5469: https://flow360.atlassian.net/browse/FXC-5469

Adds discriminated_union() to the values_tuple fields of SimulationMap and SimulationDataMap so pydantic v2 uses the type tag to select the correct union variant directly, preventing spurious ModeSimulation error logs during deserialization.


Note

Low Risk
Type-annotation-only change to Pydantic model fields plus a regression test; main risk is unintended deserialization incompatibility for any union variants missing/incorrect type tags.

Overview
Prevents spurious ERROR-level logs during Pydantic v2 deserialization of SimulationMap/SimulationDataMap by switching their values_tuple fields to use discriminated_union(...), so union selection is driven by the type tag instead of trial-and-error validation.

Adds a regression test asserting SimulationDataMap round-trip validation emits no logs above WARNING, and records the fix in CHANGELOG.md.

Written by Cursor Bugbot for commit 0be8dff. This will update automatically on new commits. Configure here.

@dmarek-flex dmarek-flex self-assigned this Feb 11, 2026
@dmarek-flex dmarek-flex added the RF label Feb 11, 2026
… fields

Add discriminated_union() to the values_tuple fields of SimulationMap
and SimulationDataMap so pydantic v2 uses the type tag to select the
correct union variant directly. This prevents spurious ModeSimulation
error logs during deserialization caused by pydantic's trial-and-error
union resolution triggering side-effect-logging validators.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dmarek-flex dmarek-flex force-pushed the dmarek/FXC-5469-sim-type-union-discriminator branch from bebe352 to 0be8dff Compare February 11, 2026 16:05
@dmarek-flex dmarek-flex marked this pull request as ready for review February 11, 2026 16:06
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

sd_map = make_simulation_data_map()

with AssertLogLevel("WARNING"):
SimulationDataMap.model_validate(sd_map.model_dump())
Copy link

Choose a reason for hiding this comment

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

Test requires WARNING log that may not exist

Low Severity

AssertLogLevel("WARNING") requires at least one WARNING-level log to be present during the context. If the model_validate roundtrip doesn't emit any warning, the assertion framework raises an error at the "Log was not recorded but requested log level is not None" check. Every other usage of AssertLogLevel("WARNING") in the codebase pairs it with a specific contains_str to confirm a known warning exists. This test implicitly assumes warnings will be emitted, making it fragile to future changes that clean up validation warnings.

Fix in Cursor Fix in Web

@github-actions
Copy link
Contributor

Diff Coverage

Diff: origin/develop...HEAD, staged and unstaged changes

  • tidy3d/components/data/index.py (100%)
  • tidy3d/components/index.py (100%)

Summary

  • Total: 4 lines
  • Missing: 0 lines
  • Coverage: 100%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant