> ## Documentation Index
> Fetch the complete documentation index at: https://docs.devin.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Debug a Bug Report End-to-End

export const UseCaseHero = ({title, description, prompt, category, features, devinUrl, agent, intent, playbookId, type}) => {
  const encodedPrompt = encodeURIComponent(prompt || '');
  const tag = 'docs-use-case-gallery';
  const utm = 'utm_source=docs&utm_medium=use-case-gallery&utm_campaign=hero-cta';
  const agentParams = (agent ? '&agent=' + agent : '') + (intent ? '&intent=' + intent : '') + (playbookId ? '&playbookId=' + playbookId : '');
  const devinHref = type === 'schedule' ? 'https://app.devin.ai/settings/schedules/create?' + utm + agentParams + (prompt ? '&prompt=' + encodedPrompt : '') : type === 'review' ? 'https://app.devin.ai/review?' + utm : agent === 'ada' ? 'https://app.devin.ai/search?' + utm + '&noSubmit=true' + (prompt ? '&prompt=' + encodedPrompt : '') : devinUrl ? devinUrl.includes('?') ? devinUrl + '&' + utm + agentParams : devinUrl + '?' + utm + agentParams : prompt ? 'https://app.devin.ai/?tags=' + tag + '&' + utm + agentParams + '&prompt=' + encodedPrompt : 'https://app.devin.ai/?' + utm + agentParams;
  const buttonLabel = type === 'schedule' ? 'Schedule in Devin ↗' : type === 'review' ? 'Set Up Devin Review ↗' : agent === 'advanced' ? 'Try in Devin ↗' : agent === 'dana' ? 'Try in Dana ↗' : agent === 'ada' ? 'Try in Ask Devin ↗' : 'Try in Devin ↗';
  const featureList = features ? features.split(',').map(f => f.trim()) : [];
  return <div className="uc-hero">
      <div className="uc-hero-inner">
        <div className="uc-hero-left">
          <h1 className="uc-hero-title">{title}</h1>
          <p className="uc-hero-desc">{description}</p>
          <div>
            <a href={devinHref} target="_blank" rel="noopener noreferrer" className="try-in-devin-btn">
              {buttonLabel}
            </a>
          </div>
        </div>
        <div className="uc-hero-meta">
          <div className="uc-meta-item">
            <span className="uc-meta-label">Author</span>
            <span className="uc-meta-value">Cognition</span>
          </div>
          <div className="uc-meta-item">
            <span className="uc-meta-label">Category</span>
            <span className="uc-meta-value">{category}</span>
          </div>
          {featureList.length > 0 && <div className="uc-meta-item">
              <span className="uc-meta-label">Features</span>
              <span className="uc-meta-value">{featureList.join(', ')}</span>
            </div>}
        </div>
      </div>
    </div>;
};

export const PromptBlock = ({children, type, agent, intent, playbookId}) => {
  var utm = 'utm_source=docs&utm_medium=use-case-gallery&utm_campaign=prompt-block';
  var tag = 'docs-use-case-gallery';
  var agentParams = (agent ? '&agent=' + agent : '') + (intent ? '&intent=' + intent : '') + (playbookId ? '&playbookId=' + playbookId : '');
  var label = type === 'schedule' ? 'Schedule in Devin' : type === 'playbook' ? 'Create Playbook' : type === 'knowledge' ? 'Add to Knowledge' : agent === 'advanced' ? 'Try in Devin' : agent === 'dana' ? 'Try in Dana' : agent === 'ada' ? 'Try in Ask Devin' : 'Try in Devin';
  var buildUrl = function (text) {
    var encoded = encodeURIComponent(text);
    if (type === 'schedule') return 'https://app.devin.ai/settings/schedules/create?' + utm + agentParams + '&prompt=' + encoded;
    if (type === 'playbook') return 'https://app.devin.ai/settings/playbooks/create?' + utm + '&body=' + encoded;
    if (type === 'knowledge') return 'https://app.devin.ai/knowledge?' + utm + '&body=' + encoded;
    if (agent === 'ada') return 'https://app.devin.ai/search?' + utm + '&noSubmit=true&prompt=' + encoded;
    return 'https://app.devin.ai/?tags=' + tag + '&' + utm + agentParams + '&prompt=' + encoded;
  };
  const ref = React.useRef(null);
  const [href, setHref] = React.useState('#');
  React.useEffect(() => {
    if (!ref.current) return;
    var codeEl = ref.current.querySelector('pre code');
    if (codeEl) {
      var text = codeEl.textContent.trim();
      if (text) setHref(buildUrl(text));
    }
    var header = ref.current.querySelector('[data-component-part="code-block-header"]');
    if (header && !header.querySelector('.prompt-block-devin-link')) {
      var link = document.createElement('a');
      link.href = href;
      link.target = '_blank';
      link.rel = 'noopener noreferrer';
      link.className = 'prompt-block-devin-link';
      link.style.cssText = 'display:inline-flex;align-items:center;gap:6px;text-decoration:none;color:#fff;font-size:11px;font-weight:500;padding:4px 10px;border-radius:6px;white-space:nowrap;background:#317CFF;transition:background 0.2s;margin-left:8px;';
      link.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg> ' + label;
      link.onmouseenter = function () {
        link.style.background = '#2968D9';
      };
      link.onmouseleave = function () {
        link.style.background = '#317CFF';
      };
      header.appendChild(link);
    }
    var existingLink = ref.current.querySelector('.prompt-block-devin-link');
    if (existingLink && href !== '#') existingLink.href = href;
  });
  return <div className="prompt-block" ref={ref}>{children}</div>;
};

<UseCaseHero title="Debug a Bug Report End-to-End" description="Hand Devin a bug report with Datadog logs and database access, and get back a root-cause analysis and fix PR." prompt="Use the Datadog MCP to find the most frequent error in production from the past 24 hours. Pull the full stack trace and related logs, query the read-only database replica for any relevant data, trace the root cause in the codebase, and open a PR with a fix and regression test." category="Incident Response" features="MCP" />

<div className="uc-detail-wrapper">
  <Tip>For a more detailed Datadog integration guide, [click here](/enterprise/integrations/datadog).</Tip>

  <Steps>
    <Step title="Connect Datadog">
      Devin needs access to your Datadog logs to search for errors related to the bug. If you haven't already, enable the Datadog MCP:

      1. Go to **Settings > Connections > MCP servers** and find **Datadog**
      2. Click **Enable**, select your Datadog site/region, and provide two headers:
         * `DD-API-KEY` — from your [Datadog API keys page](https://app.datadoghq.com/organization-settings/api-keys)
         * `DD-APPLICATION-KEY` — from your [Datadog application keys page](https://app.datadoghq.com/organization-settings/application-keys)

      Once connected, Devin can search logs, pull error traces, and correlate issues with deploys — all from inside the session. See [MCP Marketplace](/integrations/overview) for full setup details.
    </Step>

    <Step title="Give Devin read-only database access">
      For data bugs — wrong values, missing fields, broken queries — Devin is dramatically more effective when it can verify the data state directly. Pass a read-only connection string as a [Secret](/product-guides/secrets):

      1. Go to **Settings > Secrets** and add a new secret:
         * **Name**: `DATABASE_READ_REPLICA_URL`
         * **Value**: `postgresql://readonly_user:password@read-replica.internal:5432/production`
      2. Add a note like: *"Read-only connection to the production read replica. Safe for SELECT queries only."*

      Alternatively, connect a database MCP (PostgreSQL, MySQL, etc.) in **Settings > Connections > MCP servers** — Devin can use either approach to query your data.

      <Tip>Always use a read replica or a user with SELECT-only permissions. Devin never needs write access to investigate a bug. If you're concerned about expensive queries impacting performance, point Devin at a dedicated read replica or an existing analytics replica that's separate from your production database.</Tip>
    </Step>

    <Step title="Send Devin the bug report">
      Paste the bug report directly into a Devin session. Include as much context as the reporter gave you — when it started, who's affected, what's wrong, and where. For a structured investigation, use the [`!triage` template playbook](https://app.devin.ai/settings/playbooks/14fed18b89d44713a26e673cf258f548?utm_source=docs\&utm_medium=use-case-gallery) — duplicate it and customize the steps for your stack.

      <PromptBlock>
        ```txt Debug billing page bug theme={null}
        Bug report from support: Pro plan users are seeing "undefined" instead of
        their company name on the billing page. This started after last Friday's
        deploy (around 2026-02-13 18:00 UTC).

        Steps to investigate:
        1. Use Datadog to pull error logs for the billing service since Friday —
           look for null reference errors or API response changes
        2. Query the read replica to check whether Pro plan users actually have a
           company_name value: SELECT id, company_name, plan FROM users WHERE plan = 'pro' LIMIT 20
        3. Check git log for Friday's deploy — what changed in the billing page
           or user API response?
        4. Identify the root cause and fix it
        5. Add a regression test that would catch this if it happened again
        6. Run the app locally and verify the billing page renders correctly
           using your browser
        7. Open a PR with the fix
        ```
      </PromptBlock>

      The more specific the report, the faster Devin finds the answer. "Since Friday's deploy" lets Devin narrow the Datadog time window. "Pro plan users" tells it exactly which records to query.
    </Step>

    <Step title="Devin investigates and fixes">
      With Datadog and database access connected, Devin runs a full investigation:

      **Pulls Datadog logs** — Searches for errors on the billing service since Friday, filtering by service name and error status. Finds a spike in `TypeError: Cannot read property 'name' of undefined` starting at 18:12 UTC on the deploy date.

      **Queries the database** — Runs `SELECT id, company_name, plan FROM users WHERE plan = 'pro' LIMIT 20` against the read replica. Confirms that Pro users *do* have `company_name` values — the data is fine, so the bug is in the code.

      **Traces the code change** — Checks `git log --since="2026-02-13"` and finds commit `a1b2c3d` that refactored the user API response, renaming `company` to `organization`. The billing page at `src/pages/billing/BillingHeader.tsx` still references `user.company.name`.

      **Writes the fix** — Updates `BillingHeader.tsx` to use `user.organization?.name ?? 'Your Company'` and adds a regression test that renders the component with both the old and new API response shapes.

      **Verifies in the browser** — Starts the dev server, opens the billing page in Devin's built-in browser, and confirms the company name now renders correctly for a test user.

      **Opens a PR** with the fix, test, and a description explaining the root cause and impact (all Pro and Enterprise users, \~350 accounts).
    </Step>

    <Step title="Follow up">
      Once the fix PR is merged, you can ask Devin to sweep for related issues or add monitoring:

      <PromptBlock>
        ```txt Find other references to the old field theme={null}
        The root cause was user.company being renamed to user.organization in the
        API response. Search the entire frontend for other references to
        "user.company" and update them all.
        ```
      </PromptBlock>

      If you want Devin to remember something from this investigation for next time, just tell it — e.g., *"Remember that the user API uses `user.organization`, not `user.company`."* Devin will propose a [Knowledge](/product-guides/knowledge) entry that you can review and save. This way, future sessions start with the context your team has already learned.
    </Step>
  </Steps>
</div>
