Skip to content

fix: Panic on missing operator in Reload handler#1439

Closed
ashnaaseth2325-oss wants to merge 1 commit into
dora-rs:mainfrom
ashnaaseth2325-oss:fix/runtime-reload-unwrap
Closed

fix: Panic on missing operator in Reload handler#1439
ashnaaseth2325-oss wants to merge 1 commit into
dora-rs:mainfrom
ashnaaseth2325-oss:fix/runtime-reload-unwrap

Conversation

@ashnaaseth2325-oss
Copy link
Copy Markdown
Contributor

1. SUMMARY

This PR fixes a runtime panic in the Reload event handler by safely handling missing operator channels instead of unwrapping. The change is localized to binaries/runtime/src/lib.rs in the run() function and aligns behavior with existing patterns used in other event handlers.


2. FIX

// BEFORE
operator_channels
    .get(&operator_id)
    .unwrap()
    .send_async(Event::Reload { operator_id: Some(operator_id) })
    .await;

// AFTER
let Some(operator_channel) = operator_channels.get(&operator_id) else {
    tracing::warn!("received Reload event for unknown operator `{operator_id}`");
    continue;
};

operator_channel
    .send_async(Event::Reload { operator_id: Some(operator_id) })
    .await;

3. VERIFICATION

Triggered a Reload event with a missing operator_id. Previously, this caused a panic; now it logs a warning and continues execution, confirming the fix.

@ashnaaseth2325-oss ashnaaseth2325-oss marked this pull request as draft March 18, 2026 14:37
Prevents a panic when a Reload event arrives with an unknown
operator_id. Uses the same let-else pattern already applied to
Event::Input and Event::InputClosed in the same match block.

Signed-off-by: ashnaaseth2325-oss <ashnaaseth2325@gmail.com>
@ashnaaseth2325-oss ashnaaseth2325-oss force-pushed the fix/runtime-reload-unwrap branch from 16cfae8 to 452a2dd Compare March 18, 2026 14:52
@ashnaaseth2325-oss ashnaaseth2325-oss marked this pull request as ready for review March 18, 2026 17:11
@ashnaaseth2325-oss
Copy link
Copy Markdown
Contributor Author

Hello @phil-opp,
Please review this PR.
Thanks!

@ashnaaseth2325-oss
Copy link
Copy Markdown
Contributor Author

Hi @phil-opp, following up on this PR .
Could you please take a look when convenient? Thanks!

@ashnaaseth2325-oss
Copy link
Copy Markdown
Contributor Author

Hi @phil-opp,
Please review.Thanks!

@phil-opp
Copy link
Copy Markdown
Collaborator

Sorry for the delay, but please don't ping me so often.

Needs a rebase, then we can merge

@phil-opp phil-opp added the waiting-for-author The pull request requires adjustments by the PR author. label Apr 8, 2026
@heyong4725
Copy link
Copy Markdown
Collaborator

Hi @ashnaaseth2325-oss — thanks for spotting this panic and the clean fix. Closing this PR but the fix is being rescued and the credit is preserved in #1850.

Your analysis was right: the Reload handler was the only outlier in the surrounding match block — Event::Input and Event::InputClosed both already used the let-else + warn; continue; pattern, and Event::Reload was still unwrapping. Your fix made the three handlers consistent, which is exactly the right shape for this kind of map-lookup-then-send code path.

@phil-opp approved on 2026-03-29 with one ask — "Needs a rebase, then we can merge" — but you didn't get back to it. I'm sorry if the review tone discouraged you from following up; the rebase ask was just a mechanical update against main, not a substantive concern, and the work itself was solid.

#1850 is your commit cherry-picked onto current main verbatim — the git Author field stays as you (cherry-pick preserves authorship), and the rescue commit body explicitly references this PR. When #1850 lands, your name is on the merge commit history as the original author.

Two notes for next time, both small:

  1. It's OK to wait longer between pings. Phil-opp's "please don't ping me so often" was a friendly process note, not a sign that the PR was unwelcome. For a small approved PR like this, even a single follow-up after 2-3 weeks would have been fine. You did good work; the PR was approved on the merits.

  2. For "needs a rebase" asks, a one-line git pull --rebase origin main and git push --force-with-lease is usually all that's needed. If that ever feels intimidating on a small PR, mention it in a comment — reviewers can sometimes do it for you, or point at the conflict surface so you know what you're up against.

Reopen anything you'd like to revisit, or pick another good first issue when you have time. Thanks again for the contribution.

@heyong4725 heyong4725 closed this May 17, 2026
heyong4725 added a commit that referenced this pull request May 17, 2026
…ue of #1439) (#1850)

fix(runtime): replace unwrap with guard in Reload event handler

Prevents a panic when a Reload event arrives with an unknown
operator_id. Uses the same let-else pattern already applied to
Event::Input and Event::InputClosed in the same match block.

Rescue of #1439 (ashnaaseth2325-oss). Phil-opp approved the
original PR on 2026-03-29 with one ask -- "Needs a rebase, then
we can merge" -- but the author hasn't returned in 7 weeks. The
fix is unchanged from the approved version (the only conflict
was merge-base drift; the actual hunk applies cleanly to current
main and lines up exactly with the let-else pattern at
binaries/runtime/src/lib.rs:264, 291).

Co-authored-by: ashnaaseth2325-oss <ashnaaseth2325@gmail.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-for-author The pull request requires adjustments by the PR author.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants