Skip to content

Conversation

@eichhorl
Copy link
Contributor

@eichhorl eichhorl commented Jan 7, 2026

Many places in the repository use the following structure to convert an optional ID protobuf type:

let id = *_id_try_from_protobuf(try_from_option_field(
    id_proto_option,
    field_name_str,
)?)?

This is confusing since it abuses the fact that TryFrom<T> is implemented for all T. Specifically, the call to try_from_option_field doesn't actually do any conversion, it simply extracts the value out of the option, or returns an error if no value exists.

This PR switches all of these occurences to their *_id_try_from_option equivalent, similar to what was done in 1292045 for the NodeId:

let id = *_id_try_from_option(
    id_proto_option,
    field_name_str,
)?

For UserId, such a function had to be introduced first. In the process of doing that I removed an unnecessary .unwrap() and return an error instead.

@github-actions github-actions bot added the chore label Jan 7, 2026
@eichhorl eichhorl changed the title chore: try from option chore: CON-1315 Switch proto conversions to *_id_try_from_option Jan 7, 2026
@eichhorl eichhorl marked this pull request as ready for review January 7, 2026 10:37
@eichhorl eichhorl requested review from a team as code owners January 7, 2026 10:37
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

This pull request changes code owned by the Governance team. Therefore, make sure that
you have considered the following (for Governance-owned code):

  1. Update unreleased_changelog.md (if there are behavior changes, even if they are
    non-breaking).

  2. Are there BREAKING changes?

  3. Is a data migration needed?

  4. Security review?

How to Satisfy This Automatic Review

  1. Go to the bottom of the pull request page.

  2. Look for where it says this bot is requesting changes.

  3. Click the three dots to the right.

  4. Select "Dismiss review".

  5. In the text entry box, respond to each of the numbered items in the previous
    section, declare one of the following:

  • Done.

  • $REASON_WHY_NO_NEED. E.g. for unreleased_changelog.md, "No
    canister behavior changes.", or for item 2, "Existing APIs
    behave as before.".

Brief Guide to "Externally Visible" Changes

"Externally visible behavior change" is very often due to some NEW canister API.

Changes to EXISTING APIs are more likely to be "breaking".

If these changes are breaking, make sure that clients know how to migrate, how to
maintain their continuity of operations.

If your changes are behind a feature flag, then, do NOT add entrie(s) to
unreleased_changelog.md in this PR! But rather, add entrie(s) later, in the PR
that enables these changes in production.

Reference(s)

For a more comprehensive checklist, see here.

GOVERNANCE_CHECKLIST_REMINDER_DEDUP

@eichhorl eichhorl dismissed github-actions[bot]’s stale review January 7, 2026 10:58
  1. No behavior changes
  2. No breaking changes
  3. No data migration needed
  4. No security review needed
@eichhorl eichhorl added this pull request to the merge queue Jan 12, 2026
Merged via the queue into master with commit 03d9b80 Jan 12, 2026
49 of 50 checks passed
@eichhorl eichhorl deleted the eichhorl/try-from-option branch January 12, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants