Skip to content

fix(device): report a refused listed report rate as not applied - #2736

Open
jvelie wants to merge 1 commit into
AprilNEA:masterfrom
jvelie:fix/report-rate-onboard-refusal
Open

jvelie wants to merge 1 commit into
AprilNEA:masterfrom
jvelie:fix/report-rate-onboard-refusal

Conversation

@jvelie

@jvelie jvelie commented Dec 3, 2026

Copy link
Copy Markdown

Summary

A G Pro Wireless (wpid 4079) in onboard mode lists 125/250/500/1000 Hz on
0x8060, but refuses a write of any of them with InvalidArgument and keeps the
rate its onboard profile sets. The write path expected a device like this to
acknowledge the write and keep its own rate, so the refusal came out as a raw
HID++ error:

openlogi api report-rate --device "slot 1 on receiver …" --set 500
{"ok":false,"error":{"code":"device_error","message":"HID++ feature error during WriteReportRate for feature 0x8060: InvalidArgument"}}

Now, when a write of a listed rate is refused with InvalidArgument and the
device still reports a different rate, the answer is ReportRateNotApplied,
the same as the acknowledged case:

{"ok":false,"error":{"code":"readback_mismatch","message":"device reports 1000 Hz after a write of 500 Hz"}}

Any other refusal keeps the device's own error. The settings app already locks
the rate pills in onboard mode, so this mostly affects openlogi api.

Changes

  • device: set_report_rate_on_channel re-reads the rate after an
    InvalidArgument refusal and answers ReportRateNotApplied when the device
    kept another rate.
  • core: ReportRateNotApplied doc mentions the refused case. No wire change.

Testing

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets -- -D warnings (with RUSTFLAGS=-D warnings)
  • cargo test --workspace: 4735 passed, 0 failed
  • New device tests: a 0x8060 mouse refusing a listed rate with
    InvalidArgument gives ReportRateNotApplied; a Busy refusal keeps
    HidppFeature { kind: Busy }.

Hardware, Windows 11: on a G Pro Wireless in onboard mode, api report-rate --set 500 now gives the readback_mismatch answer above and the mouse stays at
1000 Hz. A PRO Gaming Keyboard (0x8060, no onboard profile) still changes
rate.

A G Pro Wireless in onboard mode lists 125-1000 Hz on 0x8060 but refuses
a write of any of them with InvalidArgument, keeping the rate its
profile sets. The write path expected such a device to acknowledge and
keep its own, so the refusal surfaced as a raw HID++ feature error.

When a write of a rate the device lists is refused with InvalidArgument
and the device still reports another rate, answer ReportRateNotApplied,
as for the acknowledged case. Other refusals keep the device's error.
@greptile-apps

greptile-apps Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Confidence Score: 1/5RetriggerView in Greptile

[Medium impact] The change affects how report-rate writes are reported to callers.

The refusal read must fit inside the write deadline, and the new tests must satisfy the repository's test requirements before merging.

Findings

  1. P0 A refusal becomes a timeout ▶
  2. P1 New tests lack required deadlines ▶

Summary

The PR turns a listed report-rate refusal into ReportRateNotApplied when a fresh read confirms another rate.

  • Refused report-rate writes can now report the rate the mouse kept.

Intent acknowledged: jvelie explicitly identifies the changed error category as the purpose of this fix.

Reviews (1) · Last reviewed commit: "fix(device): report a refused listed rep..." · Reviewed by Greptile

) {
return error;
}
match control.current(HidppOperation::WriteReportRate).await {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P0 A refusal becomes a timeout

Blocking. If a wireless mouse returns InvalidArgument and then stops answering, refusal_of_listed_rate starts a five-second read inside the agent's five-second write deadline. The outer deadline cancels the read before _ => error can return the original refusal. The caller gets RequestTimedOut instead.

This violates the repository requirement that each nested read fit inside its caller's deadline. Give this read a smaller budget and preserve the refusal on expiry. Add a refused_write_with_silent_readback_preserves_refusal test through the agent deadline.

Rule Used: Severity: high. Every nested I/O step has its own timeout that fits inside the caller's deadline, and a test asserts the arithmetic. An advisory read the device may ignore (LED, hosts info) gets a budget of hundreds of milliseconds and reads as unkno... (source)

Comment on lines +326 to +330
let shared = mouse_channel(&mouse, behind_receiver()).await;

let error = set_report_rate_on(&shared, ReportRate::new(500))
.await
.expect_err("the onboard profile keeps 1 kHz");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 New tests lack required deadlines

Blocking. Both new tests await channel setup and device writes without a test-owned timeout or an expiry message. This violates the repository requirement that every async test wait have both. Wrap each test's async work in a bounded wait that names what stalled.

The PR also omits the required counter-proof. State that reverting the refusal conversion makes a_listed_rate_the_device_refuses_is_not_applied fail. No counter-proof was run during this review.

Rule Used: Severity: medium. Every bug fix ships a regression test that fails without the fix, and the PR states the counter-proof (the reverted line or the killed mutant). A test that passes with the fix reverted is not a regression test: ask for inputs where ... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant