Skip to content

Commit ce6833d

Browse files
alistair3149malberts
authored andcommitted
Add empty revisions response
1 parent 46fd1d1 commit ce6833d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/tools/get-page-history.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,8 @@ async function handleGetPageHistoryTool(
4949
params
5050
);
5151

52-
if ( !data?.revisions ) {
53-
// It's possible for data to be non-null but revisions to be missing
54-
// if the API call was successful but the page has no revisions
55-
// or due to other valid API responses.
56-
// We treat this as an error for the tool's purpose if data itself is null.
57-
const errorMessage = data ? 'No revisions found for page' : 'Failed to retrieve page data: No data returned from API';
52+
if ( !data ) {
53+
const errorMessage = 'Failed to retrieve page data: No data returned from API';
5854
return {
5955
content: [
6056
{ type: 'text', text: errorMessage } as TextContent
@@ -63,6 +59,14 @@ async function handleGetPageHistoryTool(
6359
};
6460
}
6561

62+
if ( data.revisions.length === 0 ) {
63+
return {
64+
content: [
65+
{ type: 'text', text: 'No revisions found for page' } as TextContent
66+
]
67+
};
68+
}
69+
6670
return {
6771
content: data.revisions.map( getPageHistoryToolResult )
6872
};

0 commit comments

Comments
 (0)