Skip to content

Adds 'spo file roleassignment list' command. Closes #6191 - #7280

Draft
nanddeepn wants to merge 3 commits into
pnp:mainfrom
nanddeepn:issue-6191-1
Draft

nanddeepn wants to merge 3 commits into
pnp:mainfrom
nanddeepn:issue-6191-1

Conversation

@nanddeepn

Copy link
Copy Markdown
Contributor

Adds 'spo file roleassignment list' command. Closes #6191

Copilot AI review requested due to automatic review settings May 22, 2026 12:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds the ability to list SharePoint file role assignments via a new command and centralizes file/permissions retrieval logic in the spo utility.

Changes:

  • Updated SharePoint REST calls to use decodedUrl in GetFolderByServerRelativePath/GetFileByServerRelativePath requests
  • Added spo.getFileByUrl() and spo.getFileRoleAssignments() helpers and refactored spo file get to reuse them
  • Introduced new spo file roleassignment list command with tests and documentation

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/utils/spo.ts Adds helper methods for file retrieval and role assignments; updates REST parameter casing
src/utils/spo.spec.ts Updates URL expectations for decodedUrl and adds tests for new helpers
src/m365/spo/commands/file/file-roleassignment-list.ts New command to list role assignments for a file by URL or ID
src/m365/spo/commands/file/file-roleassignment-list.spec.ts Unit tests for the new command behavior and validation
src/m365/spo/commands/file/file-get.ts Refactors permission retrieval to use shared spo.getFileRoleAssignments()
src/m365/spo/commands/file/file-get.spec.ts Updates tests to stub spo.getFileRoleAssignments()
src/m365/spo/commands.ts Registers new command constant
docs/src/config/sidebars.ts Adds the new command doc to the sidebar
docs/docs/cmd/spo/file/file-roleassignment-list.mdx Adds documentation page for the new command

Comment thread src/utils/spo.ts Outdated
Comment thread src/utils/spo.spec.ts
Comment thread src/m365/spo/commands/file/file-roleassignment-list.spec.ts
Comment thread docs/docs/cmd/spo/file/file-roleassignment-list.mdx
Comment thread src/utils/spo.spec.ts Outdated
Comment thread src/utils/spo.spec.ts Outdated
@milanholemans

Copy link
Copy Markdown
Contributor

Thanks, we'll try to review it ASAP!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The documented -i alias and required default output are missing, with additional validation, typing, test, and documentation gaps.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 Medium severity · 2 Low severity

Open (4)
Resolved since last review (4)
Previously missed (5)

In code that hasn't changed since last review

Medium severity Add the missing -i alias for the fileId option

src/​m365/​spo/​commands/​file/​file-roleassignment-list.ts:55

The issue and this page document -i as the fileId alias, but this option is registered only as --fileId, so invocations using -i <guid> are rejected as unknown. Add the short alias to the option declaration.

Medium severity Shape role assignments and declare default text properties

src/​m365/​spo/​commands/​file/​file-roleassignment-list.ts:100

The command logs the raw nested role-assignment objects, but the issue requires default text properties PrincipalId, Member/Title, and comma-separated RoleDefinitionBindings/Name. Without shaping those nested values (or extending the property filtering) and declaring the defaults, text output exposes the full response instead of the specified columns.

Low severity Add a Permissions section to the command page

docs/​docs/​cmd/​spo/​file/​file-roleassignment-list.mdx:44

This new command page has no ## Permissions section, so users cannot determine the minimum delegated and application permissions required for the read request. Add the permissions table before the response section.

Low severity Add representative JSON, text, CSV, and Markdown examples

docs/​docs/​cmd/​spo/​file/​file-roleassignment-list.mdx:50

All four response examples are empty code blocks, so the reference page does not show the returned role-assignment shape and does not satisfy the required JSON, text, CSV, and Markdown samples. Add representative output for each format.

Low severity Migrate fileUrl/fileId validation to the Zod schema

src/​m365/​spo/​commands/​file/​file-roleassignment-list.ts:78

This new command uses the legacy optionSets/validator pattern for the required fileUrl/fileId XOR. New command implementations use a refined Zod schema for this constraint (for example, file-version-keep.ts:12-47); migrate this validation so the command participates in the current option schema pipeline.

Comment thread src/utils/spo.spec.ts
Comment thread src/utils/spo.ts
@MartinM85

Copy link
Copy Markdown
Contributor

Hi @nanddeepn, could you please check the findings from Copilot? Thank you

@nanddeepn

Copy link
Copy Markdown
Contributor Author

Hi @MartinM85
Done

@MartinM85 MartinM85 self-assigned this Oct 17, 2026

@MartinM85 MartinM85 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for the contribution @nanddeepn 🚀
Looks good overall, just a few tiny things to consider. One major thing is to use the Zod schema for command options, but our AI skill can help you save a time.

Comment on lines +49 to +50
```json
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The example of a JSON response is missing. Same for the text, csv and md output. Could you please add the response?

: URL of the site where the file is located.

`--fileUrl [fileUrl]`
: The server- or site-relative decoded URL of the file. Specify either `fileUrl` or `fileId` but not both.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
: The server- or site-relative decoded URL of the file. Specify either `fileUrl` or `fileId` but not both.
: The server- or site-relative decoded URL of the file. Specify either `fileUrl` or `fileId`, but not both.

: The server- or site-relative decoded URL of the file. Specify either `fileUrl` or `fileId` but not both.

`-i, --fileId [fileId]`
: The UniqueId (GUID) of the file. Specify either `fileUrl` or `fileId` but not both.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
: The UniqueId (GUID) of the file. Specify either `fileUrl` or `fileId` but not both.
: The UniqueId (GUID) of the file. Specify either `fileUrl` or `fileId`, but not both.

Comment on lines +12 to +16
interface Options extends GlobalOptions {
webUrl: string;
fileUrl?: string;
fileId?: string;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please use Zod schema instead of the old way.
You can use zod-migration skill. It will convert the current options to zod schema and modify unit tests.

@MartinM85
MartinM85 marked this pull request as draft October 18, 2026 15:58

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.

New command: spo file roleassignment list

4 participants