Obtaining Code Issues
Function
This API is used to query code issues that meet specified conditions.
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
POST /v1/defect/issue-list-by-filter
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| X-Language | No | String | Definition: Language of the response. Constraints: N/A Value range: Default value: zh-cn |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| taskId | 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 |
| mergeId | No | String | Definition: Merge request ID. This parameter is only used to distinguish version and quality gate scans. Leave it blank for a version scan and pass any non-empty value for a quality gate scan. Constraints: N/A Range: N/A Default value: N/A |
| jobId | No | String | Definition: Execution ID, which is returned by the API of code check task execution. Each code check task has a unique execution ID. Leave this parameter blank for a version scan and pass a value for a quality gate scan. That is, the ID field in the response of API Querying Task Execution Record by Task ID. Constraints: N/A Value range: 1 to 32 characters. Default value: N/A |
| pageSize | No | Integer | Definition: Page size. Constraints: N/A. Value range: 1 to 200. Default value: 10 |
| page | No | Integer | Definition: Page number. Constraints: N/A Range: ≥1 Default value: N/A |
| languages | No | String | Definition: Programming language. Constraints: N/A. Value range: Default value: N/A. |
| ruleIds | No | String | Definition: Rule ID. Obtain the rule ID by calling the API for obtaining the issue statistics. The facets parameter is passed to ruleIds. In the Facet.property=ruleIds response body, FacetItem.val indicates the rule ID. Constraints: N/A Value range: N/A Default value: N/A |
| authors | No | String | Definition: Username of the issue owner. Constraints: N/A Range: N/A Default value: N/A |
| isNew | No | String | Definition: Whether only news issues are shown. Constraints: N/A Value range: Default value: N/A |
| statusIds | No | String | Definition: Issue status. Constraints: N/A. Value range: Default value: N/A. |
| severities | No | String | Definition: Issue severity. Constraints: N/A Value range: Default value: N/A |
| delayStatus | No | String | Definition: Issue phase. Constraints: N/A Value range: Default value: N/A |
| fileNames | No | String | Definition: File name for exact match. Constraints: N/A Range: N/A Default value: N/A |
| userTags | No | Array of strings | Definition: Tag. Constraints: N/A Range: N/A Default value: N/A |
| cwes | No | Array of strings | Definition: CWE ID. Constraints: N/A Value range: N/A Default value: N/A |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| status | String | Definition: Response status. Value range: |
| result | Array of IssueListByFilter objects | Definition: Code issues. |
| Parameter | Type | Description |
|---|---|---|
| total | Integer | Definition Total number of code issues. Range N/A |
| info | Array of Issue objects | Definition: Code issue. |
| Parameter | Type | Description |
|---|---|---|
| defectLevel | String | Definition: Issue severity. Value range: |
| defectStatus | String | Definition: Issue status. Value range: |
| checkerName | String | Definition: Check engine. Range: N/A |
| defectType | String | Definition: Tool rule name. Range: N/A |
| fileName | String | Definition Code file name. Range N/A |
| filePath | String | Definition: File path. Range: N/A |
| ruleId | String | Definition: Unique ID of a rule. Range: N/A |
| author | String | Definition: Owner. Range: N/A |
| 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. Range: N/A |
| ruleLanguage | String | Definition: Programming language. Value range: |
| mergeKey | String | Definition: MergeKey, that is, issue ID. Value range: 1 to 32 characters. |
| functionName | String | Definition: Function name. Range: N/A |
| isNew | String | Definition: Whether only news issues are shown. Value range: |
| delayStatus | String | Definition: Issue phase. Value range: |
| criterionType | String | Definition: Rule type. Range: N/A |
| delayStartTime | String | Definition: Delay start time (UTC). Format: yyyy-MM-ddTHH:mm:ssZ. For example, 2020-09-25T12:05:00Z. Value range: N/A |
| delayEndTime | String | Definition: Delay end time (UTC). Format: yyyy-MM-ddTHH:mm:ssZ. For example, 2020-09-25T12:05:00Z. Value range: N/A |
| approver | String | Definition The [ field is discarded.](tag:hws,hws_hk) Range N/A |
| cwe | String | Definition: CWE IDs. Range: N/A |
| statusComment | Array of Comment objects | Definition: Issue operation history. |
| fragment | Array of Fragment objects | Definition: Code snippet of the issue. |
| versionRuleId | String | Definition: Tool rule version ID. Range: N/A |
| criterionVersionRuleId | String | Definition: Rule version ID. Range: N/A |
| ruleRuleId | String | Definition: Unique ID of a tool rule. Range: N/A |
| issueId | String | Definition Trouble ticket ID. You can create a trouble ticket for a code issue on the code issue page. Range N/A |
| category | String | Definition Rule category. Range N/A |
| subcategory | String | Definition This field is deprecated. 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 [ applicant.](tag:hws,hws_hk) Range N/A |
| approver | String | Definition The [ field is discarded.](tag:hws,hws_hk) Range N/A |
| statusFrom | String | Definition Issue initial status. Range |
| statusTo | String | Definition Issue target status. Range |
| ignoreType | String | Definition Deprecated field. Range |
| Parameter | Type | Description |
|---|---|---|
| bugId | String | Definition: Code snippet ID of the issue. Range: N/A |
| lineNum | String | Definition: No. of the line where an issue occurs. Range: N/A |
| lineContent | String | Definition: Line code of the issue. Range: N/A |
| filePath | String | Definition: File path. Range: N/A |
| description | String | Definition: Issue description. Range: N/A |
| codeContextStartLine | String | Definition: Start line No. of the code context. Range: N/A |
| codeContext | String | Definition: Code context. Range: N/A |
| events | String | Definition: Traces. 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 list of issues detected in the latest version-level scan of the task whose ID is 897acf5exxx48a5013cd. The filter criteria are as follows: The issue status is to be handled or resolved, the issue severity is major, and the issue delay status is formal. The issues are queried on multiple pages, with 100 issues displayed on each page. The first page is displayed.
POST https://{endpoint}/v1/defect/issue-list-by-filter
{
"taskId" : "897acf5exxx48a5013cd",
"jobId" : "",
"mergeId" : "",
"statusIds" : "0,2",
"severities" : "1",
"delayStatus" : "0",
"isNew" : "",
"languages" : "",
"authors" : "",
"fileNames" : "",
"ruleIds" : "",
"page" : 1,
"pageSize" : 10
} Example Responses
Status code: 200
Response body of the code issue list.
{
"status" : "success",
"error" : null,
"result" : [ {
"total" : "87",
"info" : [ {
"defectLevel" : "2",
"issueId" : null,
"defectStatus" : "0",
"checkerName" : "apiengine",
"defectType" : "API_DOC_STRUCT_03",
"fileName" : "API_DOC_STRUCT_03.d.ts",
"filePath" : "API_DOC_STRUCT_03.d.ts",
"modulePath" : null,
"moduleID" : "-1",
"ruleId" : "10ccf00e72094ab99e53418fa74b1859",
"author" : "test_user",
"createdAt" : "2024-08-02T07:00:35Z",
"nickName" : "test_user",
"criterionName" : "API.DOC.STRUCT.03 The @struct tag is improperly used",
"ruleLanguage" : "TYPESCRIPT",
"owner" : null,
"mergeKey" : "15ab8c7ee14cf18a559f166f9219998e",
"functionName" : "",
"isNew" : "0",
"delayStatus" : "0",
"isHit" : null,
"criterionType" : "common",
"delayStartTime" : null,
"delayEndTime" : null,
"approver" : "",
"ruleUrl" : "",
"cwe" : null,
"statusComment" : [ ],
"fragment" : [ {
"bugId" : "a47506a9-7260-48e4-9c0c-f59783957b6c",
"lineNum" : "29",
"lineContent" : "export declare enum GridObjectSortComponentType",
"filePath" : "API_DOC_STRUCT_03.d.ts",
"description" : "API check error of [wrong scene]: JSDoc label validity verification failed. The [struct] label is not allowed. Please check the label usage method.",
"codeContextStartLine" : 24,
"codeContext" : " * @enum { string }\n * @syscap SystemCapability.ArkUI.ArkUI.Full\n * @crossplatform\n * @since 11\n */\nexport declare enum GridObjectSortComponentType {}",
"engine" : "",
"category" : "",
"subcategory" : "",
"events" : "[{\"description\":\"API check error of [wrong scene]: JSDoc label validity verification failed. The [struct] label is not allowed. Please check the label usage method.\",\"fixSuggestion\":[],\"line\":29,\"main\":true,\"path\":\"API_DOC_STRUCT_03.d.ts\",\"mainBuggyCode\":\"export declare enum GridObjectSortComponentType\",\"codeContext\":\" * @enum { string }\\n * @syscap SystemCapability.ArkUI.ArkUI.Full\\n * @crossplatform\\n * @since 11\\n */\\nexport declare enum GridObjectSortComponentType {}\",\"codeContextStartLine\":24,\"codePassage\":[],\"events\":[],\"isContextShow\":false}]",
"extendInfo" : null
} ],
"versionRuleId" : "11ef44b094c732d0a5de99700335f1a8",
"criterionVersionRuleId" : "10ccf00e72094ab99e53418fa74b1859",
"codeUrl" : null,
"ruleRuleId" : "11ef44b094c732d0a5de99700335f1a8"
} ]
} ]
} Status code: 400
A request error occurred.
{
"error_code" : "CC.xxxxxxxx.400",
"error_msg" : "Verify request parameter failed. Check whether the request parameters are correct."
} Status code: 401
The permission is insufficient.
{
"error_code" : "CC.00000003",
"error_msg" : "Authentication information expired."
} Status Codes
| Status Code | Description |
|---|---|
| 200 | Response body of the code issue list. |
| 400 | A request error occurred. |
| 401 | The permission is insufficient. |
Error Codes
See Error Codes.
What is your overall rating for this page?
Thank 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