Conversation
Add a new command `create` to the `cmd_issue` CLI group. This command
allows users to create issues with various options such as title,
description, team ID, label IDs, and assignee ID. The command also
supports output in JSON format.
Example usage:
```sh
linear issue create "New Issue" --description "Details" --team-id "team123"
```
In `client.py`, add a `create_issue` method to the `User` class to
handle the GraphQL mutation for creating issues. This method constructs
the mutation query and prints it for debugging purposes.
Example:
```python
user.create_issue(
title="New Issue",
description="Details",
team_id="team123",
label_id=["label1", "label2"],
assignee_id="assignee123"
)
```
- The `create_issue` method currently returns an empty list and does not
execute the GraphQL request. The line `# data = gql_request(query)`
should be uncommented and properly implemented.
- The `return Issue.from_dict(data["data"]["createIssue"]["issue"])`
line is unreachable due to the preceding `return []` statement. The
first return statement should be removed.
There was a problem hiding this comment.
Pull Request Overview
Adds a new create command to the linear issue CLI and implements a stub in the client for creating issues via GraphQL.
- Introduces
User.create_issueinlinear/client.pywith a GraphQL mutation template. - Registers
linear issue createcommand inlinear/cli.pywith options for title, description, team, labels, assignee, and JSON output.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| linear/client.py | Added create_issue method stub with query template. |
| linear/cli.py | Added cmd_issue.create command and option parsing. |
Comments suppressed due to low confidence (1)
linear/cli.py:59
- This new CLI command isn't covered by existing tests. Add unit or integration tests to verify
linear issue createwith various flag combinations and JSON vs. markdown output.
@cmd_issue.command("create")
| title: str, | ||
| description: Optional[str] = None, | ||
| team_id: Optional[str] = None, | ||
| label_id: Optional[str] = None, |
There was a problem hiding this comment.
The label_id parameter is annotated as Optional[str] but used with json.dumps on a sequence; update the type to Optional[List[str]] (or appropriate iterable) to match its actual usage.
| label_id: Optional[str] = None, | |
| label_id: Optional[list[str]] = None, |
| # data = gql_request(query) | ||
| print(query) | ||
| return [] |
There was a problem hiding this comment.
The GraphQL request call is commented out, so the mutation is never executed. Uncomment and implement data = gql_request(query) before processing the response.
| # data = gql_request(query) | |
| print(query) | |
| return [] | |
| data = gql_request(query) |
| return [] | ||
| return Issue.from_dict(data["data"]["createIssue"]["issue"]) |
There was a problem hiding this comment.
This return [] prevents any real issue object from being returned and makes the subsequent Issue.from_dict unreachable. Remove the stub return so the actual response is returned.
| return [] | |
| return Issue.from_dict(data["data"]["createIssue"]["issue"]) | |
| raise NotImplementedError("GraphQL request functionality is not yet implemented.") | |
| # return Issue.from_dict(data["data"]["createIssue"]["issue"]) |
| mutation CreateIssue { | ||
| createIssue(input: { | ||
| title: "%s" | ||
| description: "%s" | ||
| teamId: "%s" | ||
| labelIds: %s | ||
| assigneeId: "%s" |
There was a problem hiding this comment.
Inline string interpolation in GraphQL queries can lead to injection vulnerabilities. Switch to using GraphQL variables or ensure proper escaping of user input.
| mutation CreateIssue { | |
| createIssue(input: { | |
| title: "%s" | |
| description: "%s" | |
| teamId: "%s" | |
| labelIds: %s | |
| assigneeId: "%s" | |
| mutation CreateIssue($title: String!, $description: String, $teamId: String, $labelIds: [String!], $assigneeId: String) { | |
| createIssue(input: { | |
| title: $title | |
| description: $description | |
| teamId: $teamId | |
| labelIds: $labelIds | |
| assigneeId: $assigneeId |
| title: str, | ||
| description: Optional[str], | ||
| team_id: Optional[str], | ||
| label_id: Optional[str], |
There was a problem hiding this comment.
The CLI option --label-id is multiple=True, so it yields a tuple. Update the function signature to label_id: Tuple[str, ...] (or List[str]) instead of Optional[str].
| label_id: Optional[str], | |
| label_id: Tuple[str, ...], |
| json: bool, | ||
| ): | ||
| """ | ||
| linear issue create <title> [--description <description>] |
There was a problem hiding this comment.
The docstring only mentions title and --description, but the command now supports team, labels, assignee, and JSON flags. Update it to reflect all available options.
| linear issue create <title> [--description <description>] | |
| linear issue create --title <title> [--description <description>] [--team-id <team-id>] | |
| [--label-id <label-id>] [--assignee-id <assignee-id>] [--json] | |
| Options: | |
| --title <title> The title of the issue (required). | |
| --description <description> A detailed description of the issue (optional). | |
| --team-id <team-id> The ID of the team to assign the issue to (optional). | |
| --label-id <label-id> One or more label IDs to associate with the issue (optional). | |
| --assignee-id <assignee-id> The ID of the assignee for the issue (optional). | |
| --json Output the issue in JSON format (optional). |
Add a new command
createto thecmd_issueCLI group. This commandallows users to create issues with various options such as title,
description, team ID, label IDs, and assignee ID. The command also
supports output in JSON format.
Example usage:
In
client.py, add acreate_issuemethod to theUserclass tohandle the GraphQL mutation for creating issues. This method constructs
the mutation query and prints it for debugging purposes.
Example:
create_issuemethod currently returns an empty list and does notexecute the GraphQL request. The line
# data = gql_request(query)should be uncommented and properly implemented.
return Issue.from_dict(data["data"]["createIssue"]["issue"])line is unreachable due to the preceding
return []statement. Thefirst return statement should be removed.