ms-teams-cli icon indicating copy to clipboard operation
ms-teams-cli copied to clipboard

presence set: --expiration is unvalidated, and the help names pairs setPresence rejects

Open aberoham opened this issue 3 months ago • 0 comments

Two problems with teams presence set, both from the flags rather than the transport.

1. --expiration is passed through unchecked.

Graph documents expirationDuration as an ISO 8601 duration with a valid range of PT5M to PT4H, and applies a five-minute default when it is absent (setPresence). The CLI accepts any string. --expiration 1h, --expiration PT10H and --expiration banana all cost a network round trip and come back as a 400 the caller has to interpret. An unattended caller is the one that can least afford to.

The range is documented, small, and deterministic, so it can be checked locally before the request is sent, and fail as invalid input (exit 2) rather than as an API error.

2. The help text advertises values setPresence rejects.

/// Availability: Available, Busy, DoNotDisturb, Away, Offline, etc.
/// Activity: Available, InACall, InAMeeting, Presenting, etc.

— src/cli/presence.rs:38-41

Offline and InAMeeting are not among the combinations setPresence accepts. The documented list is exactly five pairs:

availability activity
Available Available
Busy InACall
Busy InAConferenceCall
Away Away
DoNotDisturb Presenting

Those values do occur on the presence resource when reading someone's presence, which is probably where the help text came from, but set cannot send them.

Not proposed: rejecting an undocumented availability/activity pair locally. Graph may accept more than it documents, and a local allow-list would turn that into a false rejection. Correcting the help text is enough.

presence status --expiry is likewise unvalidated. It is left alone here: a malformed datetime gets a clean 400 from Graph, where a malformed duration does not.

aberoham avatar Aug 28 '26 15:08 aberoham