|
6 | 6 | "encoding/json" |
7 | 7 | "fmt" |
8 | 8 | "io" |
| 9 | + "log" |
9 | 10 | "net/http" |
10 | 11 | "strings" |
11 | 12 | "time" |
@@ -152,6 +153,7 @@ func SyncProjectBugFixWorkflowToJira(c *gin.Context) { |
152 | 153 | req.Header.Set("Content-Type", "application/json") |
153 | 154 | req.Header.Set("Accept", "application/json") |
154 | 155 |
|
| 156 | + // Use context from request for proper cancellation propagation |
155 | 157 | client := &http.Client{Timeout: 30 * time.Second} |
156 | 158 | resp, err := client.Do(req) |
157 | 159 | if err != nil { |
@@ -187,26 +189,29 @@ func SyncProjectBugFixWorkflowToJira(c *gin.Context) { |
187 | 189 | return |
188 | 190 | case 404: |
189 | 191 | websocket.BroadcastBugFixJiraSyncFailed(workflowID, workflow.GithubIssueNumber, "Jira project not found") |
190 | | - c.JSON(http.StatusBadRequest, gin.H{"error": "Jira project not found", "details": string(body)}) |
| 192 | + // Don't expose Jira error details to user - may contain sensitive info |
| 193 | + log.Printf("Jira 404 error details: %s", string(body)) |
| 194 | + c.JSON(http.StatusBadRequest, gin.H{"error": "Jira project not found"}) |
191 | 195 | return |
192 | 196 | default: |
193 | | - websocket.BroadcastBugFixJiraSyncFailed(workflowID, workflow.GithubIssueNumber, fmt.Sprintf("Jira API error: %s", string(body))) |
194 | | - c.JSON(http.StatusServiceUnavailable, gin.H{"error": fmt.Sprintf("Failed to create Jira issue (status %d)", resp.StatusCode), "details": string(body)}) |
| 197 | + websocket.BroadcastBugFixJiraSyncFailed(workflowID, workflow.GithubIssueNumber, "Jira API error") |
| 198 | + // Log details for debugging, but don't expose to user |
| 199 | + log.Printf("Jira API error (status %d): %s", resp.StatusCode, string(body)) |
| 200 | + c.JSON(http.StatusServiceUnavailable, gin.H{"error": fmt.Sprintf("Failed to create Jira issue (status %d)", resp.StatusCode)}) |
195 | 201 | return |
196 | 202 | } |
197 | 203 |
|
198 | 204 | // Parse JSON response |
199 | 205 | var result map[string]interface{} |
200 | 206 | if err := json.Unmarshal(body, &result); err != nil { |
201 | | - // Log the raw response for debugging |
202 | | - fmt.Printf("ERROR: Failed to parse Jira response as JSON: %v\n", err) |
| 207 | + // Log the raw response for debugging (server-side only) |
| 208 | + log.Printf("ERROR: Failed to parse Jira response as JSON: %v", err) |
203 | 209 | bodyLen := len(body) |
204 | | - fmt.Printf("Response body (first 500 chars): %s\n", string(body[:min(500, bodyLen)])) |
| 210 | + log.Printf("Response body (first 500 chars): %s", string(body[:min(500, bodyLen)])) |
205 | 211 | websocket.BroadcastBugFixJiraSyncFailed(workflowID, workflow.GithubIssueNumber, "Invalid Jira response") |
| 212 | + // Don't expose Jira response body to user - may contain sensitive details |
206 | 213 | c.JSON(http.StatusInternalServerError, gin.H{ |
207 | | - "error": "Failed to parse Jira response", |
208 | | - "details": err.Error(), |
209 | | - "responsePreview": string(body[:min(200, bodyLen)]), |
| 214 | + "error": "Failed to parse Jira response", |
210 | 215 | }) |
211 | 216 | return |
212 | 217 | } |
@@ -422,40 +427,6 @@ func formatGitHubJiraLinkComment(jiraTaskKey, jiraTaskURL string, workflow *type |
422 | 427 | return comment.String() |
423 | 428 | } |
424 | 429 |
|
425 | | -// formatGitHubJiraUpdateComment formats the comment to post on GitHub Issue when updating Jira task |
426 | | -func formatGitHubJiraUpdateComment(jiraTaskKey, jiraTaskURL string, workflow *types.BugFixWorkflow) string { |
427 | | - var comment strings.Builder |
428 | | - |
429 | | - comment.WriteString("## 🔄 Jira Task Updated\n\n") |
430 | | - comment.WriteString(fmt.Sprintf("Jira task [**%s**](%s) has been updated with the latest information.\n\n", jiraTaskKey, jiraTaskURL)) |
431 | | - |
432 | | - // Add links to analysis documents if available |
433 | | - if workflow.Annotations != nil { |
434 | | - hasGists := false |
435 | | - if bugReviewGist := workflow.Annotations["bug-review-gist-url"]; bugReviewGist != "" { |
436 | | - if !hasGists { |
437 | | - comment.WriteString("### 📄 Latest Analysis\n\n") |
438 | | - hasGists = true |
439 | | - } |
440 | | - comment.WriteString(fmt.Sprintf("- [Bug Review & Assessment](%s)\n", bugReviewGist)) |
441 | | - } |
442 | | - if implGist := workflow.Annotations["implementation-gist-url"]; implGist != "" { |
443 | | - if !hasGists { |
444 | | - comment.WriteString("### 📄 Latest Analysis\n\n") |
445 | | - hasGists = true |
446 | | - } |
447 | | - comment.WriteString(fmt.Sprintf("- [Implementation Details](%s)\n", implGist)) |
448 | | - } |
449 | | - if hasGists { |
450 | | - comment.WriteString("\n") |
451 | | - } |
452 | | - } |
453 | | - |
454 | | - comment.WriteString("*Synchronized by vTeam BugFix Workspace*") |
455 | | - |
456 | | - return comment.String() |
457 | | -} |
458 | | - |
459 | 430 | // getSuccessMessage returns appropriate success message |
460 | 431 | func getSuccessMessage(created bool, jiraTaskKey string) string { |
461 | 432 | if created { |
|
0 commit comments