Skip to main content
A plugin registered with findings:write can publish findings on a trail: comments tied to a line, a range, a file or the whole change, each with an optional severity and confidence. For example, a security scanner starts a review when a trail opens or updates, publishes what it found, and resolves each finding once a later push fixes it. Findings appear on the trail’s diff next to the code they’re about.
Trail findings are experimental. Field names may change before the contract is final.

What you need

  • findings:write, on your plugin’s installation token. Ask Entire to add it when you register your plugin. It also lets you read findings, but grants no repository read or push access.
  • contents:read, to read the code you’re reviewing and receive trail events. The token you write findings with doesn’t need it.
  • An access token scoped to the repository for writing findings. Mint it with this body:
Send every call below to the repository’s api_base_url, under /api/v1, with the access token as bearer token. Trails must be enabled on the repository.

Start a review

Findings belong to a review. Start one for the commit you analyzed:
Every body field is optional. head_sha and base_sha are full 40-character SHAs; the trail’s current head and base fill whichever you omit. Pass the head_sha you analyzed so your findings attach to that code, even if someone pushes while you work. A 201 returns the review:
Store review_id. Only your installation can publish to that review or change its findings.

Publish findings

Publish your findings on the review, with an optional summary:
The whole request applies or none of it does. It also marks the review complete, so publish everything you found for that commit in one request. To report no findings, send an empty comments array, with a summary if you like. location.granularity decides what else location needs: start_column, end_column, nearby_text and language are optional. selected_text and nearby_text help keep a finding attached to its code as the trail changes. The response has the completed review and one result per finding, in request order:
Store each comment.id with its client_id. You need the ID to resolve the finding later.

Retry safely

Send an Idempotency-Key header with both requests. Retrying with the same key and body returns the first response rather than starting a second review or publishing twice. client_id protects each finding as well. Publishing a client_id the review already has, with the same payload, returns it with status existing instead of creating a duplicate. The same client_id with a different payload fails the request.

Keep findings current

Update a finding when its state changes, such as when a later push fixes it:
Send only the fields you’re changing: body, severity, confidence, status or status_reason. Moving a finding to resolved or dismissed requires a non-empty status_reason. Set status back to open to reopen it. When someone pushes new code, start a new review for the new head rather than adding to an earlier one. A finding tied to code that has since changed can become stale. It keeps its status, but lists of current findings leave it out.

Read findings

List the trail’s findings with GET /api/v1/repos/{repo_id}/trails/{number}/reviews/comments. The list includes other reviewers’ findings, so match on your stored review_id to find yours. By default it returns current findings that aren’t dismissed. Filter with ?status=, ?severity= and ?stale=current|stale|any. While the response has a next_cursor, pass it back as ?cursor= for the next page.

Findings and merge gates

Findings your plugin publishes don’t count toward a trail’s Agent review gate, whatever their severity, and never block a merge. To block a merge on your results, also report checks, which needs checks:write. Your plugin’s check gate blocks merging by default; see the plugin gate rules and Review and require checks.

What findings:write doesn’t cover

  • Changing findings on a review another installation or a person started. Those return 404.
  • Approving a trail, or posting trail comments, which need other permissions.

Errors

Errors are application/problem+json. For errors when minting the token, see Access repositories.