22const githubUsername = process . env . HUBOT_GITHUB_USERNAME
33const githubToken = process . env . HUBOT_GITHUB_TOKEN
44const organisation = "owncloud"
5+ const projectName = "QA/CI/TestAutomation"
56const projectNumber = 386
67const fastLaneColumnName = "Fastlane"
78const itemsPerRequest = 50 // number of items (issues/PRs) to fetch from the project board
@@ -21,8 +22,8 @@ const fastlaneCards = []
2122
2223const filterFastlaneCards = ( cards ) => {
2324 cards . forEach ( ( card ) => {
24- const url = card . content . url
25- const columnName = card . fieldValueByName . name
25+ const url = card ? .content ? .url
26+ const columnName = card ? .fieldValueByName ? .name
2627
2728 if ( url && columnName && columnName === fastLaneColumnName ) {
2829 fastlaneCards . push ( url )
@@ -36,6 +37,7 @@ const generateQuery = (itemArg) => {
3637 return `query {
3738 organization(login: "${ organisation } "){
3839 projectV2(number: ${ projectNumber } ){
40+ title
3941 items(${ itemArg } ) {
4042 nodes{
4143 content{
@@ -78,11 +80,37 @@ const reportFastlaneCards = (robot) =>
7880 return
7981 }
8082 const parsedBody = JSON . parse ( body )
83+
84+ if ( Object . hasOwn ( parsedBody , "errors" ) ) {
85+ const errorTypes = parsedBody . errors . map ( ( error ) => error . type )
86+ if ( errorTypes . every ( ( type ) => type === "INSUFFICIENT_SCOPES" ) ) {
87+ robot . emit (
88+ "error" ,
89+ `could not find project '${ projectName } ' . Do you have the right permissions?`
90+ )
91+ return
92+ }
93+
94+ if ( errorTypes . every ( ( type ) => type === "NOT_FOUND" ) ) {
95+ console . log ( "I am error" )
96+ robot . emit (
97+ "error" ,
98+ `could not find project'${ projectName } ' with number ${ projectNumber } `
99+ )
100+ return
101+ }
102+ }
103+
81104 if ( ! parsedBody . data ) {
82105 robot . emit ( "error" , `Response doesn't have data: '${ err } '` )
83106 return
84107 }
85108
109+ if ( parsedBody . data . organization . projectV2 . title !== projectName ) {
110+ robot . emit ( "error" , `Project title from response doesn't match` )
111+ return
112+ }
113+
86114 const items = parsedBody . data . organization . projectV2 . items
87115 endCursor = items . pageInfo . endCursor
88116
0 commit comments