{"meta":{"title":"Creating issues","intro":"Copilot Chat can help you quickly create issues without filling out every field manually.","product":"GitHub Copilot","breadcrumbs":[{"href":"/en/copilot","title":"GitHub Copilot"},{"href":"/en/copilot/tutorials","title":"Tutorials"},{"href":"/en/copilot/tutorials/copilot-chat-cookbook","title":"GitHub Copilot Chat Cookbook"},{"href":"/en/copilot/tutorials/copilot-chat-cookbook/document-code","title":"Document code"},{"href":"/en/copilot/tutorials/copilot-chat-cookbook/document-code/creating-issues","title":"Create issues"}],"documentType":"article"},"body":"# Creating issues\n\nCopilot Chat can help you quickly create issues without filling out every field manually.\n\nCreating issues manually can be time-consuming. Copilot Chat lets you create issues from natural language, and automatically fills in the title, body, labels, and other metadata based on your prompt.\n\n## Example scenario\n\nYou're working on an API service and need to add server-side validation to the `createUser` endpoint. Instead of drafting the issue manually, you use Copilot Chat to generate a detailed issue description that includes an example implementation of the validation middleware.\n\nThe following snippet shows the current implementation of the `createUser` route, before validation is added:\n\n```javascript\n// Route\napp.post('/users', validateCreateUser, (req, res) => {\n  const { username, email } = req.body;\n  // Simulate user creation\n  res.status(201).json({ message: 'User created', user: { username, email } });\n});\n```\n\n## Example prompt\n\n`In octo-org/octo-repo, create an issue to add server-side validation for the createUser API endpoint. Include an example of how to validate the request body using an existing middleware pattern. Label it with \"backend\" and \"enhancement\".`\n\n## Example response\n\n> [!NOTE] The following response is an example. Copilot Chat responses are non-deterministic, so you may get a different response from the one shown here.\n\nWhen you submit the prompt, Copilot Chat generates a draft issue based on your description and includes a code snippet. You can review and edit the draft before creating the issue.\n\n```markdown\n## Problem\nThe `createUser` API endpoint currently lacks robust server-side validation for incoming requests. To ensure data integrity and security, we should validate the request body before proceeding with user creation.\n\n**Current API endpoint:**\n// Route\napp.post('/users', validateCreateUser, (req, res) => {\n  const { username, email } = req.body;\n  // Simulate user creation\n  res.status(201).json({ message: 'User created', user: { username, email } });\n});\n\n## Proposal\n- Add server-side validation for the request body using the existing middleware pattern.\n- Ensure required fields (`username`, `email`) are present and valid.\n- Return a 400 Bad Request response if validation fails.\n\n**Example (middleware pattern):**\nfunction validateCreateUser(req, res, next) {\n  const { username, email } = req.body;\n  if (!username || !email) {\n    return res.status(400).json({ error: 'Username and email are required.' });\n  }\n  // Additional validation logic here\n  next();\n}\n\napp.post('/users', validateCreateUser, (req, res) => {\n  // ...\n});\n\n## Acceptance Criteria\n- Server-side validation middleware is added to the `createUser` endpoint.\n- Request body is properly validated.\n- Appropriate error responses are returned for invalid requests.\n```"}