Skip to content

[NOT-464] Unwrap structured scrape JSON output#48

Merged
leo-notte merged 1 commit into
mainfrom
fix/scrape-json-structured-output
Jun 18, 2026
Merged

[NOT-464] Unwrap structured scrape JSON output#48
leo-notte merged 1 commit into
mainfrom
fix/scrape-json-structured-output

Conversation

@leo-notte

@leo-notte leo-notte commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Return structured scrape data directly for instruction-based scrapes in JSON output
  • Keep non-instruction scrape JSON output as the full response
  • Add coverage for both JSON output shapes

Linear: NOT-464 https://linear.app/nottelabsinc/issue/NOT-464/notte-cli-pr-48-unwrap-structured-scrape-json-output

Tests

  • go test ./...

@greptile-apps

greptile-apps Bot commented Jun 18, 2026

Copy link
Copy Markdown

Greptile Summary

This PR changes the JSON output of instruction-based scrape commands to return the extracted structured data directly, rather than wrapping it in the full DataSpace response object. The refactoring introduces extractScrapeStructuredData as a shared helper used by both JSON and text paths.

  • JSON mode with instructions: now returns the unwrapped structured.data payload instead of the full response, removing markdown, session, and other envelope fields from machine-readable output.
  • Text mode restructure: the inline success/error/data checks are replaced with calls to the new helper, which uses json.Marshal+json.Unmarshal instead of the previous AsBaseModel() call to flatten the union-type wrapper.
  • Tests: two new JSON-shape assertions are added — one confirming markdown is absent for instruction scrapes, and one confirming markdown is present for non-instruction scrapes.

Confidence Score: 5/5

Safe to merge — the change is narrowly scoped to JSON output formatting for instruction-based scrapes and does not touch auth, data persistence, or session logic.

The core logic is straightforward and the new helper is well-guarded. Both JSON output shapes are covered by the updated tests. The one edge case (nil resp.Structured falling through in text mode) is cosmetic and unreachable under normal API responses.

No files require special attention.

Important Files Changed

Filename Overview
internal/cmd/output_helpers.go Refactors PrintScrapeResponse to extract structured data via a new helper; JSON mode with instructions now returns unwrapped structured data instead of the full response
internal/cmd/sessions_test.go Adds assertions verifying both JSON output shapes (structured-only for instruction scrapes, full response otherwise) and updates fixture data to include realistic structured fields

Reviews (2): Last reviewed commit: "Unwrap structured scrape JSON output" | Re-trigger Greptile

@leo-notte leo-notte merged commit c2ad115 into main Jun 18, 2026
4 checks passed
@giordano-lucas giordano-lucas changed the title Unwrap structured scrape JSON output [NOT-464] Unwrap structured scrape JSON output Jul 10, 2026
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