Querying the Details and Context Code of an Issue
Function
This API is used to query the details and context code of an issue based on the MergeKey.
Calling Method
For details, see Calling APIs.
Authorization Information
Each account root user has all the permissions required to call all APIs, but IAM users must be assigned the following required identity policy-based permissions. For details about the required permissions, see Permissions Policies and Supported Actions.
|
Action |
Access Level |
Resource Type (*: required) |
Condition Key |
Alias |
Dependencies |
|---|---|---|---|---|---|
|
codeartscheck:task:getReport |
Read |
task * |
- |
- |
- |
|
- |
codeartscheck:ProjectId |
URI
GET /v1/defect
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
task_id |
Yes |
String |
Definition : Task ID, returned by the API for creating a check task. Each code check task, branch task, or incremental task generated through an API has a unique ID. Obtain the ID by calling the API used to . id indicates the task ID. Constraints: N/A Value range: 1 to 32 characters. Default value: N/A |
|
merge_id |
No |
String |
Definition Merge request ID or commit ID. They are used to query quality gate tasks. Constraints N/A Range N/A Default Value N/A |
|
job_id |
No |
String |
Definition Execution record ID, that is, the unique ID of each version or quality gate scan. The ID is used to query quality gate tasks. Constraints N/A Range N/A Default Value N/A |
|
merge_key |
Yes |
String |
Definition: MergeKey, that is, issue ID. Constraints: N/A Value range: N/A Default value: N/A |
Request Parameters
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
status |
String |
Definition: Response status. Value range: |
|
result |
SingleDefectAndContext object |
Definition: Details and context code of an issue. |
|
Parameter |
Type |
Description |
|---|---|---|
|
approver |
String |
Definition: Username of the reviewer who reviews the ignored issues. Range: N/A |
|
language |
String |
Definition: Programming language. Value range: |
|
filePath |
String |
Definition: File path. Value range: N/A |
|
line |
Integer |
Definition: No. of the line where an issue occurs. Value range: N/A |
|
functionName |
String |
Definition: Name of the function where an issue occurs. Value range: N/A |
|
checkerName |
String |
Definition: Tool name. Value range: N/A |
|
checkerVersion |
String |
Definition: Tool version. Value range: N/A |
|
ruleName |
String |
Definition: Tool rule name. Value range: N/A |
|
defectLevel |
String |
Definition: Issue severity. Value range: |
|
createdAt |
String |
Definition: Issue detection time (UTC). Format: yyyy-MM-ddTHH:mm:ssZ. For example, 2020-09-25T12:05:00Z. Value range: N/A |
|
criterionName |
String |
Definition: Rule name. Value range: N/A |
|
defectStatus |
String |
Definition: Issue status. Value range: |
|
occursInfo |
OccursInfo object |
Definition: Code snippet. |
|
nickName |
String |
Definition: Issue owner. Value range: N/A |
|
statusComment |
Array of Comment objects |
Definition: Issue operation history. |
|
ruleId |
String |
Definition: Rule ID. Value range: N/A |
|
Parameter |
Type |
Description |
|---|---|---|
|
occurId |
String |
Definition: Code snippet ID of the issue. Value range: N/A |
|
occurDescription |
String |
Definition: Issue description. Value range: N/A |
|
engine |
String |
Definition: Tool name. Value range: N/A |
|
sourceCodeUrl |
String |
Definition: Source code file URL. Value range: N/A |
|
events |
Array of Events objects |
Definition: Traces. |
|
Parameter |
Type |
Description |
|---|---|---|
|
description |
String |
Definition: Issue description. Value range: N/A |
|
fixSuggestions |
Array of strings |
Definition: Fix suggestions. |
|
line |
Integer |
Definition: No. of the line where an issue occurs in the file. Value range: N/A |
|
startLine |
Integer |
Definition: This field is deprecated. Value range: N/A |
|
endLine |
Integer |
Definition: This field is deprecated. Value range: N/A |
|
main |
Boolean |
Definition: This field is deprecated. Value range: N/A |
|
path |
String |
Definition: File path. Value range: N/A |
|
tag |
String |
Definition: This field is deprecated. Value range: N/A |
|
mainBuggyCode |
String |
Definition: Code snippet where the main event of the issue occurred. Value range: N/A |
|
codeContext |
String |
Definition: This field is deprecated. Value range: N/A |
|
codeContextStartLine |
Integer |
Definition: Start line No. of the code context. Value range: N/A |
|
codePassage |
Array of CodeLine objects |
Definition: Code context. |
|
events |
Array of DefectEvents objects |
Definition: Traces. |
|
Parameter |
Type |
Description |
|---|---|---|
|
lineNumber |
Integer |
Definition: Line No. Value range: N/A |
|
lineContent |
String |
Definition: Code. Value range: N/A |
|
Parameter |
Type |
Description |
|---|---|---|
|
events |
Array of DefectEvents objects |
Definition Traces. |
|
description |
String |
Definition Issue description. Range N/A |
|
fix_suggestions |
Array of strings |
Definition: Fix suggestions. |
|
line |
Integer |
Definition No. of the line where the issue occurs in the file. Range N/A |
|
end_line |
Integer |
Definition This field is deprecated. Range N/A |
|
main |
Boolean |
Definition This field is deprecated. Range N/A |
|
path |
String |
Definition File path. Range N/A |
|
tag |
String |
Definition This field is deprecated. Range N/A |
|
main_buggy_code |
String |
Definition Code snippet where the main event of the issue occurred. Range N/A |
|
code_context |
String |
Definition Code context. Range N/A |
|
code_context_start_line |
Integer |
Definition Start line No. of the code context. Range N/A |
|
Parameter |
Type |
Description |
|---|---|---|
|
id |
Integer |
Definition: Operation history ID. Range: N/A |
|
comments |
String |
Definition: Remarks. Value range: 1 to 256 characters. |
|
mergeKey |
String |
Definition: MergeKey, that is, issue ID. Value range: 1 to 32 characters. |
|
createTime |
String |
Definition: Occurrence time (UTC). Format: yyyy-MM-ddTHH:mm:ssZ. For example, 2020-09-25T12:05:00Z. Value range: N/A |
|
applicant |
String |
Definition: Operator. Range: N/A |
|
statusFrom |
String |
Definition: Issue initial status. Range: N/A |
|
statusTo |
String |
Definition: Issue target status. Range: N/A |
Status code: 400
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Definition: Error code. Value range: N/A |
|
error_msg |
String |
Definition: Error message. Value range: N/A |
Status code: 401
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Definition: Error code. Value range: N/A |
|
error_msg |
String |
Definition: Error message. Value range: N/A |
Example Requests
Query the details and context of the issue whose MergeKey is 08abe0dcxxx817d18e189 in the version-level task whose ID is 897acf5exxx48a5013cd.
GET https://{endpoint}/v1/defects?task_id=897acf5exxx48a5013cd&merge_key=08abe0dcxxx817d18e189
Example Responses
Status code: 200
Response body for querying the details and context code of an issue.
{
"status" : "success",
"result" : {
"approver" : "devcloud_codecheck_xxxxxx_01",
"language" : "JAVA",
"filePath" : "code/BoolParser.java",
"line" : 255,
"functionName" : "equalityExpression()",
"checkerName" : "sonarqube",
"checkerVersion" : "202406",
"ruleName" : "java:S134",
"defectLevel" : "1",
"createdAt" : "2024-02-04T04:02:07Z",
"criterionName" : "Control flow statements \"if\", \"for\", \"while\", \"switch\" and \"try\" should not be nested too deeply",
"defectStatus" : "5",
"occursInfo" : [ {
"occurId" : "d46c0c8c-8a56-xxx-adc4-xxx63d26",
"occurDescription" : "Refactor this code to not nest more than 3 if/for/while/switch/try statements.",
"ruleUrl" : "",
"engine" : "Sonarqube",
"sourceCodeUrl" : "codehub/2111708128/home?ref=master&isFile=true&filePath=code%2FBoolParser.java",
"events" : [ {
"description" : "Assigning: \"x\" = \"0\".",
"line" : 13,
"path" : "code/BoolParser.java",
"tag" : "",
"mainBuggyCode" : "",
"codeContext" : "",
"codeContextStartLine" : 0,
"codePassage" : [ {
"lineNumber" : 1,
"lineContent" : "// $ANTLR 2.7.7 (20060906): \"src/test/resources/test04.g\" -> \"BoolParser.java\"$"
}, {
"lineNumber" : 2,
"lineContent" : ""
}, {
"lineNumber" : 3,
"lineContent" : "package com.bulain.antlr.bool.ast;"
}, {
"lineNumber" : 4,
"lineContent" : ""
}, {
"lineNumber" : 5,
"lineContent" : "import java.math.*;"
}, {
"lineNumber" : 6,
"lineContent" : "import com.bulain.antlr.util.*;"
}, {
"lineNumber" : 7,
"lineContent" : ""
}, {
"lineNumber" : 8,
"lineContent" : ""
}, {
"lineNumber" : 9,
"lineContent" : "import antlr.TokenBuffer;"
}, {
"lineNumber" : 10,
"lineContent" : "import antlr.TokenStreamException;"
}, {
"lineNumber" : 11,
"lineContent" : "import antlr.TokenStreamIOException;"
}, {
"lineNumber" : 12,
"lineContent" : "import antlr.ANTLRException;"
}, {
"lineNumber" : 13,
"lineContent" : "import antlr.LLkParser;"
}, {
"lineNumber" : 14,
"lineContent" : "import antlr.Token;"
}, {
"lineNumber" : 15,
"lineContent" : "import antlr.TokenStream;"
}, {
"lineNumber" : 16,
"lineContent" : "import antlr.RecognitionException;"
}, {
"lineNumber" : 17,
"lineContent" : "import antlr.NoViableAltException;"
}, {
"lineNumber" : 18,
"lineContent" : "import antlr.MismatchedTokenException;"
}, {
"lineNumber" : 19,
"lineContent" : "import antlr.SemanticException;"
}, {
"lineNumber" : 20,
"lineContent" : "import antlr.ParserSharedInputState;"
}, {
"lineNumber" : 21,
"lineContent" : "import antlr.collections.impl.BitSet;"
}, {
"lineNumber" : 22,
"lineContent" : "import antlr.collections.AST;"
}, {
"lineNumber" : 23,
"lineContent" : "import java.util.Hashtable;"
}, {
"lineNumber" : 24,
"lineContent" : "import antlr.ASTFactory;"
}, {
"lineNumber" : 25,
"lineContent" : "import antlr.ASTPair;"
}, {
"lineNumber" : 26,
"lineContent" : "import antlr.collections.impl.ASTArray;"
}, {
"lineNumber" : 27,
"lineContent" : ""
}, {
"lineNumber" : 28,
"lineContent" : "public class BoolParser extends antlr.LLkParser implements BoolParserTokenTypes"
} ],
"isContextShow" : false,
"startReadParam" : 1,
"endReadParam" : 28
}, {
"description" : "Condition \"cond01(p1)\", taking false branch.",
"line" : 14,
"path" : "code/BoolParser.java",
"tag" : "",
"mainBuggyCode" : "",
"codeContext" : "",
"codeContextStartLine" : 0,
"codePassage" : [ {
"lineNumber" : 1,
"lineContent" : "// $ANTLR 2.7.7 (20060906): \"src/test/resources/test04.g\" -> \"BoolParser.java\"$"
}, {
"lineNumber" : 2,
"lineContent" : ""
}, {
"lineNumber" : 3,
"lineContent" : "package com.bulain.antlr.bool.ast;"
}, {
"lineNumber" : 4,
"lineContent" : ""
}, {
"lineNumber" : 5,
"lineContent" : "import java.math.*;"
}, {
"lineNumber" : 6,
"lineContent" : "import com.bulain.antlr.util.*;"
}, {
"lineNumber" : 7,
"lineContent" : ""
}, {
"lineNumber" : 8,
"lineContent" : ""
}, {
"lineNumber" : 9,
"lineContent" : "import antlr.TokenBuffer;"
}, {
"lineNumber" : 10,
"lineContent" : "import antlr.TokenStreamException;"
}, {
"lineNumber" : 11,
"lineContent" : "import antlr.TokenStreamIOException;"
}, {
"lineNumber" : 12,
"lineContent" : "import antlr.ANTLRException;"
}, {
"lineNumber" : 13,
"lineContent" : "import antlr.LLkParser;"
}, {
"lineNumber" : 14,
"lineContent" : "import antlr.Token;"
}, {
"lineNumber" : 15,
"lineContent" : "import antlr.TokenStream;"
}, {
"lineNumber" : 16,
"lineContent" : "import antlr.RecognitionException;"
}, {
"lineNumber" : 17,
"lineContent" : "import antlr.NoViableAltException;"
}, {
"lineNumber" : 18,
"lineContent" : "import antlr.MismatchedTokenException;"
}, {
"lineNumber" : 19,
"lineContent" : "import antlr.SemanticException;"
}, {
"lineNumber" : 20,
"lineContent" : "import antlr.ParserSharedInputState;"
}, {
"lineNumber" : 21,
"lineContent" : "import antlr.collections.impl.BitSet;"
}, {
"lineNumber" : 22,
"lineContent" : "import antlr.collections.AST;"
}, {
"lineNumber" : 23,
"lineContent" : "import java.util.Hashtable;"
}, {
"lineNumber" : 24,
"lineContent" : "import antlr.ASTFactory;"
}, {
"lineNumber" : 25,
"lineContent" : "import antlr.ASTPair;"
}, {
"lineNumber" : 26,
"lineContent" : "import antlr.collections.impl.ASTArray;"
}, {
"lineNumber" : 27,
"lineContent" : ""
}, {
"lineNumber" : 28,
"lineContent" : "public class BoolParser extends antlr.LLkParser implements BoolParserTokenTypes"
}, {
"lineNumber" : 29,
"lineContent" : " {"
} ],
"isContextShow" : false,
"startReadParam" : 1,
"endReadParam" : 29
}, {
"description" : "In expression \"1 / x\", division by expression \"x\" which may be zero has undefined behavior.",
"line" : 87,
"main" : true,
"path" : "code/BoolParser.java",
"tag" : "",
"mainBuggyCode" : "",
"codeContext" : " // POTENTIAL FLAW: \n // POTENTIAL FLAW: \n // POTENTIAL FLAW: \n // POTENTIAL FLAW: \n // POTENTIAL FLAW: \n return 1 / x;",
"codeContextStartLine" : 82,
"codePassage" : [ {
"lineNumber" : 72,
"lineContent" : "\t\treturnAST = null;"
}, {
"lineNumber" : 73,
"lineContent" : "\t\tASTPair currentAST = new ASTPair();"
}, {
"lineNumber" : 74,
"lineContent" : "\t\tAST logicalExpression_AST = null;"
}, {
"lineNumber" : 75,
"lineContent" : "\t\t"
}, {
"lineNumber" : 76,
"lineContent" : "\t\ttry { // for error handling"
}, {
"lineNumber" : 77,
"lineContent" : "\t\t\texpression();"
}, {
"lineNumber" : 78,
"lineContent" : "\t\t\tastFactory.addASTChild(currentAST, returnAST);"
}, {
"lineNumber" : 79,
"lineContent" : "\t\t\tlogicalExpression_AST = (AST)currentAST.root;"
}, {
"lineNumber" : 80,
"lineContent" : "\t\t}"
}, {
"lineNumber" : 81,
"lineContent" : "\t\tcatch (RecognitionException ex) {"
}, {
"lineNumber" : 82,
"lineContent" : "\t\t\treportError(ex);"
}, {
"lineNumber" : 83,
"lineContent" : "\t\t\trecover(ex,_tokenSet_0);"
}, {
"lineNumber" : 84,
"lineContent" : "\t\t}"
}, {
"lineNumber" : 85,
"lineContent" : "\t\treturnAST = logicalExpression_AST;"
}, {
"lineNumber" : 86,
"lineContent" : "\t}"
}, {
"lineNumber" : 87,
"lineContent" : "\t"
}, {
"lineNumber" : 88,
"lineContent" : "\tpublic final void expression() throws RecognitionException, TokenStreamException {"
}, {
"lineNumber" : 89,
"lineContent" : "\t\t"
}, {
"lineNumber" : 90,
"lineContent" : "\t\treturnAST = null;"
}, {
"lineNumber" : 91,
"lineContent" : "\t\tASTPair currentAST = new ASTPair();"
}, {
"lineNumber" : 92,
"lineContent" : "\t\tAST expression_AST = null;"
}, {
"lineNumber" : 93,
"lineContent" : "\t\t"
}, {
"lineNumber" : 94,
"lineContent" : "\t\ttry { // for error handling"
}, {
"lineNumber" : 95,
"lineContent" : "\t\t\tlogicalOrExpression();"
}, {
"lineNumber" : 96,
"lineContent" : "\t\t\tastFactory.addASTChild(currentAST, returnAST);"
}, {
"lineNumber" : 97,
"lineContent" : "\t\t\texpression_AST = (AST)currentAST.root;"
}, {
"lineNumber" : 98,
"lineContent" : "\t\t}"
}, {
"lineNumber" : 99,
"lineContent" : "\t\tcatch (RecognitionException ex) {"
}, {
"lineNumber" : 100,
"lineContent" : "\t\t\treportError(ex);"
}, {
"lineNumber" : 101,
"lineContent" : "\t\t\trecover(ex,_tokenSet_1);"
}, {
"lineNumber" : 102,
"lineContent" : "\t\t}"
} ],
"startReadParam" : 72,
"endReadParam" : 102
} ]
} ],
"nickName" : "devcloud_codecheck_xxxxxx_01",
"statusComment" : [ {
"id" : 10636330,
"comments" : "ds",
"mergeKey" : "08abe0xxxxd18e189",
"createTime" : "2024-09-26T03:34:23Z",
"applicant" : "devcloud_codecheck_xxxxxx_01",
"statusFrom" : "4",
"statusTo" : "5"
} ]
}
}
Status code: 400
Bad Request
{
"error_code" : "CC.xxxxxxxx.400",
"error_msg" : "Verify request parameter failed. Check whether the request parameters are correct."
}
Status code: 401
Unauthorized
{
"error_code" : "CC.00000003",
"error_msg" : "Authentication information expired."
}
Status Codes
|
Status Code |
Description |
|---|---|
|
200 |
Response body for querying the details and context code of an issue. |
|
400 |
Bad Request |
|
401 |
Unauthorized |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot