This is an automated email from the ASF dual-hosted git repository.

hez pushed a commit to branch release-v0.17
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/release-v0.17 by this push:
     new 1feedf987 cherrypick(v0.17.0-beta10): #5311 (missing fix) (#5346)
1feedf987 is described below

commit 1feedf9878645737a2b4ef9923548d9777b2d141
Author: Keon Amini <[email protected]>
AuthorDate: Thu Jun 1 11:30:05 2023 -0500

    cherrypick(v0.17.0-beta10): #5311 (missing fix) (#5346)
    
    * fix: fix API params for extractor + converter too, and handle nil user 
edge case
    
    * fix: e2e test update
    
    * fix: Rename serviceID to scopeID to match how v0.18 handles API params. 
This also fixes the broken e2es
---
 .../plugins/pagerduty/e2e/raw_tables/_raw_pagerduty_incidents.csv  | 6 +++---
 .../pagerduty/e2e/snapshot_tables/_tool_pagerduty_assignments.csv  | 6 +++---
 .../pagerduty/e2e/snapshot_tables/_tool_pagerduty_incidents.csv    | 6 +++---
 .../pagerduty/e2e/snapshot_tables/_tool_pagerduty_users.csv        | 4 ++--
 backend/plugins/pagerduty/tasks/incidents_collector.go             | 2 +-
 backend/plugins/pagerduty/tasks/incidents_converter.go             | 7 +++++--
 backend/plugins/pagerduty/tasks/incidents_extractor.go             | 1 +
 backend/plugins/pagerduty/tasks/task_data.go                       | 2 +-
 8 files changed, 19 insertions(+), 15 deletions(-)

diff --git 
a/backend/plugins/pagerduty/e2e/raw_tables/_raw_pagerduty_incidents.csv 
b/backend/plugins/pagerduty/e2e/raw_tables/_raw_pagerduty_incidents.csv
index 8cda8d9c8..65e43ff14 100644
--- a/backend/plugins/pagerduty/e2e/raw_tables/_raw_pagerduty_incidents.csv
+++ b/backend/plugins/pagerduty/e2e/raw_tables/_raw_pagerduty_incidents.csv
@@ -1,4 +1,4 @@
 id,params,data,url,input,created_at
-1,"{""ConnectionId"":1}","{""incident_number"": 4, ""title"": ""Crash 
reported"", ""created_at"": ""2022-11-03T06:23:06.000000Z"", ""status"": 
""triggered"", ""incident_key"": ""bb60942875634ee6a7fe94ddb51c3a09"", 
""service"": {""id"": ""PIKL83L"", ""type"": ""service_reference"", 
""summary"": ""DevService"", ""self"": 
""https://api.pagerduty.com/services/PIKL83L"";, ""html_url"": 
""https://keon-test.pagerduty.com/service-directory/PIKL83L""}, 
""assignments"": [{""at"": ""2022-11-03T06:23 [...]
-2,"{""ConnectionId"":1}","{""incident_number"": 5, ""title"": ""Slow 
startup"", ""created_at"": ""2022-11-03T06:44:28.000000Z"", ""status"": 
""acknowledged"", ""incident_key"": ""d7bc6d39c37e4af8b206a12ff6b05793"", 
""service"": {""id"": ""PIKL83L"", ""type"": ""service_reference"", 
""summary"": ""DevService"", ""self"": 
""https://api.pagerduty.com/services/PIKL83L"";, ""html_url"": 
""https://keon-test.pagerduty.com/service-directory/PIKL83L""}, 
""assignments"": [{""at"": ""2022-11-03T06:4 [...]
-3,"{""ConnectionId"":1}","{""incident_number"": 6, ""title"": ""Spamming 
logs"", ""created_at"": ""2022-11-03T06:45:36.000000Z"", ""status"": 
""resolved"", ""incident_key"": ""9f5acd07975e4c57bc717d8d9e066785"", 
""service"": {""id"": ""PIKL83L"", ""type"": ""service_reference"", 
""summary"": ""DevService"", ""self"": 
""https://api.pagerduty.com/services/PIKL83L"";, ""html_url"": 
""https://keon-test.pagerduty.com/service-directory/PIKL83L""}, 
""assignments"": [], ""last_status_change_at"": [...]
+1,"{""ConnectionId"":1,""ScopeId"":""PIKL83L""}","{""incident_number"": 4, 
""title"": ""Crash reported"", ""created_at"": ""2022-11-03T06:23:06.000000Z"", 
""status"": ""triggered"", ""incident_key"": 
""bb60942875634ee6a7fe94ddb51c3a09"", ""service"": {""id"": ""PIKL83L"", 
""type"": ""service_reference"", ""summary"": ""DevService"", ""self"": 
""https://api.pagerduty.com/services/PIKL83L"";, ""html_url"": 
""https://keon-test.pagerduty.com/service-directory/PIKL83L""}, 
""assignments"": [{"" [...]
+2,"{""ConnectionId"":1,""ScopeId"":""PIKL83L""}","{""incident_number"": 5, 
""title"": ""Slow startup"", ""created_at"": ""2022-11-03T06:44:28.000000Z"", 
""status"": ""acknowledged"", ""incident_key"": 
""d7bc6d39c37e4af8b206a12ff6b05793"", ""service"": {""id"": ""PIKL83L"", 
""type"": ""service_reference"", ""summary"": ""DevService"", ""self"": 
""https://api.pagerduty.com/services/PIKL83L"";, ""html_url"": 
""https://keon-test.pagerduty.com/service-directory/PIKL83L""}, 
""assignments"": [{" [...]
+3,"{""ConnectionId"":1,""ScopeId"":""PIKL83L""}","{""incident_number"": 6, 
""title"": ""Spamming logs"", ""created_at"": ""2022-11-03T06:45:36.000000Z"", 
""status"": ""resolved"", ""incident_key"": 
""9f5acd07975e4c57bc717d8d9e066785"", ""service"": {""id"": ""PIKL83L"", 
""type"": ""service_reference"", ""summary"": ""DevService"", ""self"": 
""https://api.pagerduty.com/services/PIKL83L"";, ""html_url"": 
""https://keon-test.pagerduty.com/service-directory/PIKL83L""}, 
""assignments"": [], "" [...]
diff --git 
a/backend/plugins/pagerduty/e2e/snapshot_tables/_tool_pagerduty_assignments.csv 
b/backend/plugins/pagerduty/e2e/snapshot_tables/_tool_pagerduty_assignments.csv
index a1b1bc317..3201f177f 100644
--- 
a/backend/plugins/pagerduty/e2e/snapshot_tables/_tool_pagerduty_assignments.csv
+++ 
b/backend/plugins/pagerduty/e2e/snapshot_tables/_tool_pagerduty_assignments.csv
@@ -1,4 +1,4 @@
 
incident_number,user_id,created_at,updated_at,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark,connection_id,assigned_at
-4,P25K520,2022-11-03T07:11:37.415+00:00,2022-11-03T07:11:37.415+00:00,"{""ConnectionId"":1}",_raw_pagerduty_incidents,1,,1,2022-11-03T07:02:36.000+00:00
-4,PQYACO3,2022-11-03T07:11:37.415+00:00,2022-11-03T07:11:37.415+00:00,"{""ConnectionId"":1}",_raw_pagerduty_incidents,1,,1,2022-11-03T06:23:06.000+00:00
-5,PQYACO3,2022-11-03T07:11:37.415+00:00,2022-11-03T07:11:37.415+00:00,"{""ConnectionId"":1}",_raw_pagerduty_incidents,2,,1,2022-11-03T06:44:37.000+00:00
+4,P25K520,2022-11-03T07:11:37.415+00:00,2022-11-03T07:11:37.415+00:00,"{""ConnectionId"":1,""ScopeId"":""PIKL83L""}",_raw_pagerduty_incidents,1,,1,2022-11-03T07:02:36.000+00:00
+4,PQYACO3,2022-11-03T07:11:37.415+00:00,2022-11-03T07:11:37.415+00:00,"{""ConnectionId"":1,""ScopeId"":""PIKL83L""}",_raw_pagerduty_incidents,1,,1,2022-11-03T06:23:06.000+00:00
+5,PQYACO3,2022-11-03T07:11:37.415+00:00,2022-11-03T07:11:37.415+00:00,"{""ConnectionId"":1,""ScopeId"":""PIKL83L""}",_raw_pagerduty_incidents,2,,1,2022-11-03T06:44:37.000+00:00
diff --git 
a/backend/plugins/pagerduty/e2e/snapshot_tables/_tool_pagerduty_incidents.csv 
b/backend/plugins/pagerduty/e2e/snapshot_tables/_tool_pagerduty_incidents.csv
index de1a59010..539209e20 100644
--- 
a/backend/plugins/pagerduty/e2e/snapshot_tables/_tool_pagerduty_incidents.csv
+++ 
b/backend/plugins/pagerduty/e2e/snapshot_tables/_tool_pagerduty_incidents.csv
@@ -1,4 +1,4 @@
 
connection_id,number,created_at,updated_at,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark,url,service_id,summary,status,urgency,created_date,updated_date
-1,4,2022-11-03T07:11:37.422+00:00,2022-11-03T07:11:37.422+00:00,"{""ConnectionId"":1}",_raw_pagerduty_incidents,1,,https://keon-test.pagerduty.com/incidents/Q3YON8WNWTZMRQ,PIKL83L,[#4]
 Crash 
reported,triggered,high,2022-11-03T06:23:06.000+00:00,2022-11-03T07:02:36.000+00:00
-1,5,2022-11-03T07:11:37.422+00:00,2022-11-03T07:11:37.422+00:00,"{""ConnectionId"":1}",_raw_pagerduty_incidents,2,,https://keon-test.pagerduty.com/incidents/Q3CZAU7Q4008QD,PIKL83L,[#5]
 Slow 
startup,acknowledged,high,2022-11-03T06:44:28.000+00:00,2022-11-03T06:44:37.000+00:00
-1,6,2022-11-03T07:11:37.422+00:00,2022-11-03T07:11:37.422+00:00,"{""ConnectionId"":1}",_raw_pagerduty_incidents,3,,https://keon-test.pagerduty.com/incidents/Q1OHFWFP3GPXOG,PIKL83L,[#6]
 Spamming 
logs,resolved,low,2022-11-03T06:45:36.000+00:00,2022-11-03T06:51:44.000+00:00
+1,4,2022-11-03T07:11:37.422+00:00,2022-11-03T07:11:37.422+00:00,"{""ConnectionId"":1,""ScopeId"":""PIKL83L""}",_raw_pagerduty_incidents,1,,https://keon-test.pagerduty.com/incidents/Q3YON8WNWTZMRQ,PIKL83L,[#4]
 Crash 
reported,triggered,high,2022-11-03T06:23:06.000+00:00,2022-11-03T07:02:36.000+00:00
+1,5,2022-11-03T07:11:37.422+00:00,2022-11-03T07:11:37.422+00:00,"{""ConnectionId"":1,""ScopeId"":""PIKL83L""}",_raw_pagerduty_incidents,2,,https://keon-test.pagerduty.com/incidents/Q3CZAU7Q4008QD,PIKL83L,[#5]
 Slow 
startup,acknowledged,high,2022-11-03T06:44:28.000+00:00,2022-11-03T06:44:37.000+00:00
+1,6,2022-11-03T07:11:37.422+00:00,2022-11-03T07:11:37.422+00:00,"{""ConnectionId"":1,""ScopeId"":""PIKL83L""}",_raw_pagerduty_incidents,3,,https://keon-test.pagerduty.com/incidents/Q1OHFWFP3GPXOG,PIKL83L,[#6]
 Spamming 
logs,resolved,low,2022-11-03T06:45:36.000+00:00,2022-11-03T06:51:44.000+00:00
diff --git 
a/backend/plugins/pagerduty/e2e/snapshot_tables/_tool_pagerduty_users.csv 
b/backend/plugins/pagerduty/e2e/snapshot_tables/_tool_pagerduty_users.csv
index a47f8b668..a679b64e0 100644
--- a/backend/plugins/pagerduty/e2e/snapshot_tables/_tool_pagerduty_users.csv
+++ b/backend/plugins/pagerduty/e2e/snapshot_tables/_tool_pagerduty_users.csv
@@ -1,3 +1,3 @@
 
connection_id,id,created_at,updated_at,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark,url,name
-1,P25K520,2022-11-03T07:11:37.418+00:00,2022-11-03T07:11:37.418+00:00,"{""ConnectionId"":1}",_raw_pagerduty_incidents,1,,https://keon-test.pagerduty.com/users/P25K520,Kian
 Amini
-1,PQYACO3,2022-11-03T07:11:37.418+00:00,2022-11-03T07:11:37.418+00:00,"{""ConnectionId"":1}",_raw_pagerduty_incidents,2,,https://keon-test.pagerduty.com/users/PQYACO3,Keon
 Amini
+1,P25K520,2022-11-03T07:11:37.418+00:00,2022-11-03T07:11:37.418+00:00,"{""ConnectionId"":1,""ScopeId"":""PIKL83L""}",_raw_pagerduty_incidents,1,,https://keon-test.pagerduty.com/users/P25K520,Kian
 Amini
+1,PQYACO3,2022-11-03T07:11:37.418+00:00,2022-11-03T07:11:37.418+00:00,"{""ConnectionId"":1,""ScopeId"":""PIKL83L""}",_raw_pagerduty_incidents,2,,https://keon-test.pagerduty.com/users/PQYACO3,Keon
 Amini
diff --git a/backend/plugins/pagerduty/tasks/incidents_collector.go 
b/backend/plugins/pagerduty/tasks/incidents_collector.go
index 3d514a38a..e7495fb73 100644
--- a/backend/plugins/pagerduty/tasks/incidents_collector.go
+++ b/backend/plugins/pagerduty/tasks/incidents_collector.go
@@ -64,7 +64,7 @@ func CollectIncidents(taskCtx plugin.SubTaskContext) 
errors.Error {
                Ctx: taskCtx,
                Params: PagerDutyParams{
                        ConnectionId: data.Options.ConnectionId,
-                       ServiceId:    data.Options.ServiceId,
+                       ScopeId:      data.Options.ServiceId,
                },
                Table: RAW_INCIDENTS_TABLE,
        }
diff --git a/backend/plugins/pagerduty/tasks/incidents_converter.go 
b/backend/plugins/pagerduty/tasks/incidents_converter.go
index 0713af07b..1b73b5ce3 100644
--- a/backend/plugins/pagerduty/tasks/incidents_converter.go
+++ b/backend/plugins/pagerduty/tasks/incidents_converter.go
@@ -72,6 +72,7 @@ func ConvertIncidents(taskCtx plugin.SubTaskContext) 
errors.Error {
                        Ctx: taskCtx,
                        Params: PagerDutyParams{
                                ConnectionId: data.Options.ConnectionId,
+                               ScopeId:      data.Options.ServiceId,
                        },
                        Table: RAW_INCIDENTS_TABLE,
                },
@@ -104,8 +105,10 @@ func ConvertIncidents(taskCtx plugin.SubTaskContext) 
errors.Error {
                                UpdatedDate:     &incident.UpdatedDate,
                                LeadTimeMinutes: leadTime,
                                Priority:        string(incident.Urgency),
-                               AssigneeId:      user.Id,
-                               AssigneeName:    user.Name,
+                       }
+                       if user != nil {
+                               domainIssue.AssigneeId = user.Id
+                               domainIssue.AssigneeName = user.Name
                        }
                        seenIncidents[incident.Number] = combined
                        boardIssue := &ticket.BoardIssue{
diff --git a/backend/plugins/pagerduty/tasks/incidents_extractor.go 
b/backend/plugins/pagerduty/tasks/incidents_extractor.go
index 8b5e6ba7a..b8a5be4a5 100644
--- a/backend/plugins/pagerduty/tasks/incidents_extractor.go
+++ b/backend/plugins/pagerduty/tasks/incidents_extractor.go
@@ -35,6 +35,7 @@ func ExtractIncidents(taskCtx plugin.SubTaskContext) 
errors.Error {
                        Ctx: taskCtx,
                        Params: PagerDutyParams{
                                ConnectionId: data.Options.ConnectionId,
+                               ScopeId:      data.Options.ServiceId,
                        },
                        Table: RAW_INCIDENTS_TABLE,
                },
diff --git a/backend/plugins/pagerduty/tasks/task_data.go 
b/backend/plugins/pagerduty/tasks/task_data.go
index a357dd016..d2521ec56 100644
--- a/backend/plugins/pagerduty/tasks/task_data.go
+++ b/backend/plugins/pagerduty/tasks/task_data.go
@@ -41,7 +41,7 @@ type PagerDutyTaskData struct {
 
 type PagerDutyParams struct {
        ConnectionId uint64
-       ServiceId    string
+       ScopeId      string
 }
 
 func DecodeAndValidateTaskOptions(options map[string]interface{}) 
(*PagerDutyOptions, errors.Error) {

Reply via email to