Skip to content

Add outlook calendargroup get command. Closes #7111#7166

Open
AlejandroGispert wants to merge 2 commits intopnp:mainfrom
AlejandroGispert:feature/outlook-calendargroup-get
Open

Add outlook calendargroup get command. Closes #7111#7166
AlejandroGispert wants to merge 2 commits intopnp:mainfrom
AlejandroGispert:feature/outlook-calendargroup-get

Conversation

@AlejandroGispert
Copy link
Contributor

@AlejandroGispert AlejandroGispert commented Mar 20, 2026

Closes #7111

Summary
Adds the missing m365 outlook calendargroup get command to retrieve a specific calendar group for a user, supporting lookup by either --id or --name (with --name resolving to an id via OData filtering).

Details
Implements m365 outlook calendargroup get with delegated vs app-only permission handling.
Enforces mutually exclusive --id/--name and --userId/--userName.
Adds unit tests and a docs page, and wires the command into the docs sidebar.

@AlejandroGispert AlejandroGispert force-pushed the feature/outlook-calendargroup-get branch from 46032d6 to 3da5852 Compare March 20, 2026 14:51
@AlejandroGispert AlejandroGispert marked this pull request as draft March 20, 2026 15:05
@AlejandroGispert AlejandroGispert force-pushed the feature/outlook-calendargroup-get branch from e63aaba to d002fb8 Compare March 20, 2026 15:57
@AlejandroGispert AlejandroGispert marked this pull request as ready for review March 20, 2026 16:01
@AlejandroGispert
Copy link
Contributor Author

Hi @milanholemans @MartinM85 , Can you check my PR?

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds the missing m365 outlook calendargroup get command to the CLI for Microsoft 365 to retrieve a specific Outlook calendar group for a user, supporting lookup by either --id or --name, and documenting/validating delegated vs app-only behavior.

Changes:

  • Introduces outlook calendargroup get command implementation with Zod validation and Graph calls
  • Adds unit tests covering key permission/lookup scenarios
  • Adds documentation page and wires it into the Docusaurus sidebar

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/m365/outlook/commands/calendargroup/calendargroup-get.ts Implements the new calendargroup get command, including permission handling and name-to-id resolution
src/m365/outlook/commands/calendargroup/calendargroup-get.spec.ts Adds unit tests for the new command (id/name, delegated/app-only, shared-scope handling)
src/m365/outlook/commands.ts Registers the new command name constant
docs/src/config/sidebars.ts Adds the new command docs page to the Outlook sidebar group
docs/docs/cmd/outlook/calendargroup/calendargroup-get.mdx Adds reference documentation for outlook calendargroup get

Comment on lines +96 to +100
const getCalendarGroupId = async (calendarGroupName: string): Promise<string> => {
const userPath = userIdentifier ? `users('${userIdentifier}')` : 'me';
const calendarGroups = await odata.getAllItems<CalendarGroup>(
`${this.resource}/v1.0/${userPath}/calendarGroups?$select=id,name&$filter=name eq '${formatting.encodeQueryParameter(calendarGroupName)}'`
);
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

userIdentifier is interpolated directly into the users('...') OData path without encoding/escaping. This breaks for valid UPNs containing characters like # (guest #EXT# users) and can also allow malformed OData paths if the identifier contains a single quote. Use formatting.encodeQueryParameter(userIdentifier) (as done in other commands) when building userPath/URLs.

Copilot uses AI. Check for mistakes.
Comment on lines +120 to +123
// For delegated access without userId/userName: use /me.
const userPath = userIdentifier ? `users('${userIdentifier}')` : 'me';
const requestUrl = `${this.resource}/v1.0/${userPath}/calendarGroups/${calendarGroupId}`;

Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

userIdentifier is used unencoded in users('...') when constructing the final requestUrl. For guest UPNs containing #EXT# this will produce an invalid URL (the # starts a fragment) and the request will fail. Encode/escape the identifier (e.g., via formatting.encodeQueryParameter) before inserting it into the URL, and adjust the unit tests that assert the raw URL for --userName accordingly.

Copilot uses AI. Check for mistakes.
…rs for API requests

- Updated the command to encode user identifiers before constructing API URLs.
- Adjusted test cases to reflect changes in user identifier handling.
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.

New command: outlook calendargroup get

2 participants