You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bugfix-309-setup-crash: Refactor token handling in CLI setup to prioritize command line input and improve validation logic. Enhance error logging for project item retrieval and update tests to cover pagination scenarios and invalid project IDs.
// Search for the item ID in the project with pagination
51590
51594
let cursor = null;
51591
51595
let projectItemId = undefined;
51596
+
let totalItemsChecked = 0;
51597
+
const maxPages = 100; // 100 * 100 = 10_000 items max to avoid runaway loops
51598
+
let pageCount = 0;
51592
51599
do {
51600
+
if (pageCount >= maxPages) {
51601
+
(0, logger_1.logError)(`Stopped after ${maxPages} pages (${totalItemsChecked} items). Issue or PR #${issueOrPullRequestNumber} not found in project.`);
51602
+
break;
51603
+
}
51604
+
pageCount += 1;
51593
51605
const projectQuery = `
51594
51606
query($projectId: ID!, $cursor: String) {
51595
51607
node(id: $projectId) {
@@ -51618,16 +51630,36 @@ class ProjectRepository {
51618
51630
projectId: project.id,
51619
51631
cursor
51620
51632
});
51621
-
const items = projectResult.node.items.nodes;
51633
+
if (projectResult.node === null) {
51634
+
(0, logger_1.logError)(`Project not found for ID "${project.id}". Ensure the project is loaded via getProjectDetail (GraphQL node ID), not the project number.`);
51635
+
throw new Error(`Project not found or invalid project ID. The project ID must be the GraphQL node ID from the API (e.g. PVT_...), not the project number.`);
(0, logger_1.logError)(`Project items pagination: hasNextPage is true but endCursor is null (page ${pageCount}, ${totalItemsChecked} items so far). Cannot fetch more.`);
51654
+
}
51655
+
cursor = null;
51656
+
}
51630
51657
} while (cursor);
51658
+
if (projectItemId === undefined) {
51659
+
(0, logger_1.logError)(`Issue or PR #${issueOrPullRequestNumber} not found in project after checking ${totalItemsChecked} items (${pageCount} page(s)). ` +
51660
+
`Link it to the project first, or wait for the board to sync.`);
51661
+
throw new Error(`Issue or pull request #${issueOrPullRequestNumber} is not in the project yet (checked ${totalItemsChecked} items). Link it to the project first, or wait for the board to sync.`);
// Search for the item ID in the project with pagination
46659
46663
let cursor = null;
46660
46664
let projectItemId = undefined;
46665
+
let totalItemsChecked = 0;
46666
+
const maxPages = 100; // 100 * 100 = 10_000 items max to avoid runaway loops
46667
+
let pageCount = 0;
46661
46668
do {
46669
+
if (pageCount >= maxPages) {
46670
+
(0, logger_1.logError)(`Stopped after ${maxPages} pages (${totalItemsChecked} items). Issue or PR #${issueOrPullRequestNumber} not found in project.`);
46671
+
break;
46672
+
}
46673
+
pageCount += 1;
46662
46674
const projectQuery = `
46663
46675
query($projectId: ID!, $cursor: String) {
46664
46676
node(id: $projectId) {
@@ -46687,16 +46699,36 @@ class ProjectRepository {
46687
46699
projectId: project.id,
46688
46700
cursor
46689
46701
});
46690
-
const items = projectResult.node.items.nodes;
46702
+
if (projectResult.node === null) {
46703
+
(0, logger_1.logError)(`Project not found for ID "${project.id}". Ensure the project is loaded via getProjectDetail (GraphQL node ID), not the project number.`);
46704
+
throw new Error(`Project not found or invalid project ID. The project ID must be the GraphQL node ID from the API (e.g. PVT_...), not the project number.`);
(0, logger_1.logError)(`Project items pagination: hasNextPage is true but endCursor is null (page ${pageCount}, ${totalItemsChecked} items so far). Cannot fetch more.`);
46723
+
}
46724
+
cursor = null;
46725
+
}
46699
46726
} while (cursor);
46727
+
if (projectItemId === undefined) {
46728
+
(0, logger_1.logError)(`Issue or PR #${issueOrPullRequestNumber} not found in project after checking ${totalItemsChecked} items (${pageCount} page(s)). ` +
46729
+
`Link it to the project first, or wait for the board to sync.`);
46730
+
throw new Error(`Issue or pull request #${issueOrPullRequestNumber} is not in the project yet (checked ${totalItemsChecked} items). Link it to the project first, or wait for the board to sync.`);
0 commit comments