pnp / pnp/cli-microsoft365

Update cliRequestOptions interface

Open
#6,568 9 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement keep-open needs peer review
Dominant language
TypeScript
Stars
1.5k
Forks
413
Avg merge
5d 6h
Merged PRs (30d)
21

Description

While using the command spo page publish, I referenced the wrong file and noticed that we were throwing the entire JSON error on failure.

Image

This is because the request we're firing has no returnType property.

https://github.com/pnp/cli-microsoft365/blob/f5e6f85a45557c6c37a1294e033fea885b03bd31/src/m365/spo/commands/page/page-publish.ts#L54-L59

This is something that happens occasionally, and we maintainers sometimes overlook things like this. Therefore I suggest that we implement a more durable solution. I can't think of a request right away that doesn't have a responseType. Let's update our request interface and make responseType a required parameter.

https://github.com/pnp/cli-microsoft365/blob/f5e6f85a45557c6c37a1294e033fea885b03bd31/src/request.ts#L10-L12

Besides responseType, I think we can also make url and headers required. If I'm not mistaken, in CLI, every request needs at least one header, else the access token is not added to the request. I know we have some anonymous commands that don't need an access token, let's check if they all can have a header.


TL;DR

Make following options required in the cliRequestOptions interface:

  • responseType
  • url
  • headers

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/request.ts to inspect cliRequestOptions, then read the request in src/m365/spo/commands/page/page-publish.ts that exposes the missing responseType. Search all request call sites and check anonymous commands for suitable headers. Done means every call satisfies required responseType, url, and headers without breaking anonymous requests.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.