Skip to content

Commit 4dbb0a9

Browse files
lorenzocbletta-code
andcommitted
Take OneNote PATCH permissions only from the PUT
A declared PATCH could carry a read-only scope, and the corrected update kept it when the path had no PUT. Permissions now come only from the generated PUT. The PATCH description also covers the delete action, which takes no content. 👾 Generated with [Letta Code](https://letta.com) Co-Authored-By: Letta Code <noreply@letta.com>
1 parent 8f346ae commit 4dbb0a9

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎packages/plugins/openapi/src/providers/microsoft/graph.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ const oneNotePatchPageContentOperation = (
682682
writeTemplate: Record<string, unknown> | undefined,
683683
): Record<string, unknown> => {
684684
// Permissions come from the generated write operation (the PUT), never from
685-
// the read operation the operationId is derived from.
685+
// the read operation the operationId is derived from or a declared PATCH.
686686
const writePermissions = writeTemplate
687687
? Object.fromEntries(
688688
["security", "x-ms-permissions"].flatMap((key) =>
@@ -707,7 +707,7 @@ const oneNotePatchPageContentOperation = (
707707
description:
708708
"Update the content of a OneNote page with an array of patch commands. Each command " +
709709
"targets an element (#<data-id>, a generated id, body, or title) and appends, inserts, " +
710-
"prepends, or replaces HTML content.",
710+
"prepends, or replaces HTML content, or deletes the element.",
711711
externalDocs: {
712712
description: "Find more info here",
713713
url: "https://learn.microsoft.com/graph/api/page-update?view=graph-rest-1.0",
@@ -745,7 +745,8 @@ const oneNotePatchPageContentOperation = (
745745
},
746746
content: {
747747
type: "string",
748-
description: "Well-formed HTML to add to the page.",
748+
description:
749+
"Well-formed HTML to add to the page. Required for every action except delete.",
749750
},
750751
},
751752
},
@@ -788,7 +789,7 @@ const normalizeMicrosoftGraphOneNotePathItem = (
788789
if (operationTemplate) {
789790
const corrected = oneNotePatchPageContentOperation(
790791
operationTemplate,
791-
isRecord(pathItem.put) ? pathItem.put : existingPatch,
792+
isRecord(pathItem.put) ? pathItem.put : undefined,
792793
);
793794
next.patch =
794795
typeof existingPatch?.operationId === "string"

‎packages/plugins/openapi/src/providers/microsoft/onenote.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,8 @@ describe("OneNote page write contract correction", () => {
440440
const variant = VARIANTS[0]!;
441441
const declared = {
442442
operationId: `${variant.operationPrefix}.PatchPagesContent`,
443+
// A read-only scope on a declared PATCH must not survive.
444+
security: delegated("Notes.Read"),
443445
requestBody: {
444446
content: {
445447
"application/json": {

0 commit comments

Comments
 (0)