Skip to content

Sanitize public auth and scrape failure messages - #1041

Merged
sidneyswift merged 4 commits into
mainfrom
codex/public-error-safety
Oct 19, 2026
Merged

sidneyswift merged 4 commits into
mainfrom
codex/public-error-safety

Conversation

@sidneyswift

@sidneyswift sidneyswift commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Caught authentication exceptions and scrape-start/provider exceptions could expose internal details to clients. Return stable public messages from the existing auth helper and shared scrape operation, and from the batch/single route catch blocks. Preserve Projects 401 message, each scrape route's status/body shape, and existing started/failed charging rules.

Follow-up to #1038 and #1039 under recoupable/mono#360; hosted verification remains separately tracked in recoupable/mono#361. This PR does not close either broader tracker.

Validation:

  • Harmless internal/provider canaries reproduce the original leaks, then pass with the repair. Tests call the actual Projects GET and both scrape POST exports; scrape transport tests use the real shared scrape operation with mocked provider/database/auth dependencies.
  • 118 tests across 21 suites pass, including contract/schema, auth, scrape operation/consumer and billing regressions.
  • pnpm run typecheck:response-contracts, pnpm lint:check, changed-file formatting and git diff --check pass.
  • Server-only diagnostic logging retains caught exceptions in auth, shared scrape and route catch blocks. A focused test checks that the shared scrape error reaches the server logger while its returned failure remains generic.

Production effect after an approved merge/release: these failure responses use generic messages instead of internal exception strings. No schema, access policy, provider dispatch or charging change is intended. No live provider calls, customer/production writes, charges, migrations, credential changes or manual deployment were performed. Current evidence is synthetic source verification; review, final-head CI and normal release verification remain required. No merge is requested by this implementation assignment.

Final-head follow-up: the first completed full CI execution at bd05d15 had 6,544 passing tests and two old raw-message expectations in socialScrapeBillingRoutes. Commit 39adac4 changes only those two expectations; all 118 affected tests now pass locally. Final-head CI must complete before this PR is considered green.

Final readback at 39adac4: all six checks pass. Unit workflow 39288428233 reports 1,211 suites / 6,546 tests passed, 11 suites / 13 tests skipped; response-contract typechecking also passes. Cubic approves this exact head with zero findings. PR remains open and unmerged.

@vercel

vercel Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
api Ready Ready Preview Oct 19, 2026 4:47pm UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 8 files

Architecture diagram
sequenceDiagram
    participant Client as External Client
    participant Auth as Auth Helper (getAuthenticatedAccountId)
    participant Projects as Projects API Route
    participant BatchRoute as Batch Scrape Route
    participant SingleRoute as Single Scrape Route
    participant ScrapeOp as Shared Scrape Operation (scrapeProfileUrl)
    participant Provider as Provider Client (e.g., LinkedIn)
    participant DB as Database
    participant Logger as Server Logger

    Note over Client,Logger: Auth Failure Path (Projects 401)
    Client->>Projects: GET /api/projects/{projectId}
    Projects->>Auth: getAuthenticatedAccountId()
    Auth->>DB: getOrCreateAccountIdByAuthToken()
    DB-->>Auth: Throws error (internal message)
    Auth->>Auth: Catch - log exception details
    Auth-->>Projects: 401 generic message (no exception detail)
    Projects-->>Client: 401 {"status":"error","message":"Failed to verify authentication token"}

    Note over Client,Logger: Scrape Start Failure (Provider Error)
    Client->>BatchRoute: POST /api/artist/socials/scrape
    BatchRoute->>ScrapeOp: scrapeProfileUrl()
    ScrapeOp->>Provider: startLinkedinProfileScraping()
    Provider-->>ScrapeOp: Throws error (internal message)
    ScrapeOp->>ScrapeOp: Catch - log generic failure event
    ScrapeOp->>ScrapeOp: Return failed state (generic message)
    ScrapeOp-->>BatchRoute: {state:"failed", error:"Failed to start scrape"}
    BatchRoute-->>Client: 200 [{runId:null, datasetId:null, error:"Failed to start scrape"}]

    Client->>SingleRoute: POST /api/socials/{id}/scrape
    SingleRoute->>ScrapeOp: scrapeProfileUrl()
    ScrapeOp->>Provider: startLinkedinProfileScraping()
    Provider-->>ScrapeOp: Throws error (internal message)
    ScrapeOp->>ScrapeOp: Catch - log generic failure event
    ScrapeOp-->>SingleRoute: {state:"failed", error:"Failed to start scrape"}
    SingleRoute-->>Client: 500 {"status":"error","error":"Failed to start scrape"}

    Note over Client,Logger: Unexpected DB Error (No Charge)
    Client->>BatchRoute: POST /api/artist/socials/scrape
    BatchRoute->>DB: selectSocials()
    DB-->>BatchRoute: Throws error (internal message)
    BatchRoute->>BatchRoute: Catch - log exception details
    BatchRoute-->>Client: 500 {"status":"error","message":"Internal server error"}
    Note over BatchRoute: No credit deduction

    Client->>SingleRoute: POST /api/socials/{id}/scrape
    SingleRoute->>DB: selectAccountSocials()
    DB-->>SingleRoute: Throws error (internal message)
    SingleRoute->>SingleRoute: Catch - log exception details
    SingleRoute-->>Client: 500 {"status":"error","error":"Internal server error"}
    Note over SingleRoute: No credit deduction
Loading

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread lib/apify/scrapeProfileUrl.ts Resolved
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Repository: recoupable/api/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0667531d-5766-4fd1-a81f-77f1eded118a
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 5 files (changes from recent commits).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: Sanitizes public auth and scrape failure responses so they return generic messages instead of internal exception strings, while retaining server-side error logging; canary tests confirm no leak and route status/body shapes are preserved.

View guided diff | Turn on auto-fix | Re-trigger cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 1 file (changes from recent commits).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: Sanitizes public auth and scrape failure responses so they return generic messages instead of internal exception strings, while retaining server-side error logging; canary tests confirm no leak and route status/body shapes are preserved.

View guided diff | Turn on auto-fix | Re-trigger cubic

This branch was successfully deployed

1 active deployment
Preview — 39adac47 Deployed Oct 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant