Skip to content

Inherit value errors from a new InvalidAttributeError - #247

Merged
llucax merged 4 commits into
frequenz-floss:v0.x.xfrom
llucax:invalid-attr-error
Jul 13, 2026
Merged

llucax merged 4 commits into
frequenz-floss:v0.x.xfrom
llucax:invalid-attr-error

Conversation

@llucax

@llucax llucax commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

As we continue to add more exception that are intended for reporting invalid data in attributes, it makes sense to have a parent class with the shared attributes for all of them.

This PR adds a new InvalidAttributeError exception and makes all existing value errors inherit from it.

Also adds a new MissingFieldError in preparation for upcoming PRs.

Part of #239.

@llucax
llucax force-pushed the invalid-attr-error branch from 3e1cea5 to ffe337a Compare July 9, 2026 12:28
@github-actions github-actions Bot added part:tests Affects the unit, integration and performance (benchmarks) tests part:grid Affects the grid protobuf definitions part:metrics Affects the metrics protobuf definitions part:microgrid Affects the microgrid protobuf definitions labels Jul 9, 2026
@llucax llucax added this to the v0.4.1 milestone Jul 9, 2026
@llucax llucax added the cmd:skip-release-notes It is not necessary to update release notes for this PR label Jul 9, 2026
@llucax
llucax force-pushed the invalid-attr-error branch from 95d0ec4 to 9953c5b Compare July 9, 2026 13:00
@llucax
llucax marked this pull request as ready for review July 9, 2026 13:01
@llucax
llucax requested a review from a team as a code owner July 9, 2026 13:01
@llucax
llucax requested review from Marenz and removed request for a team July 9, 2026 13:01
@llucax
llucax enabled auto-merge July 9, 2026 13:01
@github-actions github-actions Bot added the part:docs Affects the documentation label Jul 9, 2026
@llucax
llucax force-pushed the invalid-attr-error branch 2 times, most recently from 6c2164a to 086581a Compare July 9, 2026 13:39
llucax added 4 commits July 10, 2026 08:47
This exception will be the base for any exception raised when an
attribute that holds invalid data is accessed through a semantic
accessor.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Make `UnrecognizedEnumValueError` and `UnspecifiedEnumValueError`
inherit from `InvalidAttributeError`.

Also split exception tests as the file grew too much when adding the new
tests.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Add a new top-level exception `MissingFieldError`, sibling of
`UnspecifiedEnumValueError`, to signal that a semantic accessor was
called on a wrapper field that resolves to `None` because the underlying
field was not set on the wire.

The first user is the upcoming `Microgrid.get_delivery_area()` accessor
(delivery area may be `None`, `InvalidDeliveryArea`, or `DeliveryArea`),
but the pattern is expected to recur wherever an accessor unifies a
`T | ... | None` field into a plain `T` return.

Like `Unspecified/UnrecognizedEnumValueError`, it multi-inherits from
`ClientCommonError` and `ValueError` for convenience.

Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>
@llucax
llucax force-pushed the invalid-attr-error branch from 086581a to 00b8b76 Compare July 10, 2026 13:21
@llucax llucax self-assigned this Jul 10, 2026

@Marenz Marenz 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.

🤖 No blocking findings. Minor residual risk: the accessor tests do not explicitly assert the exceptions' instance and attr_name metadata, but this is not approval-blocking.

@llucax
llucax added this pull request to the merge queue Jul 13, 2026
Merged via the queue into frequenz-floss:v0.x.x with commit 78a6470 Jul 13, 2026
9 checks passed
@llucax
llucax deleted the invalid-attr-error branch July 13, 2026 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cmd:skip-release-notes It is not necessary to update release notes for this PR part:docs Affects the documentation part:grid Affects the grid protobuf definitions part:metrics Affects the metrics protobuf definitions part:microgrid Affects the microgrid protobuf definitions part:tests Affects the unit, integration and performance (benchmarks) tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants