Skip to content

feat(integration-jfrog): add -o json output, separated from logs - #55

Merged
KunalSin9h merged 1 commit into
mainfrom
feat/jfrog-json-output
Aug 26, 2026
Merged

feat(integration-jfrog): add -o json output, separated from logs#55
KunalSin9h merged 1 commit into
mainfrom
feat/jfrog-json-output

Conversation

@KunalSin9h

@KunalSin9h KunalSin9h commented Aug 26, 2026

Copy link
Copy Markdown
Member

What

safedep integration jfrog run now has a machine-consumable output stream, cleanly separated from operational logs.

  • Output is the user-facing result: a real state change in XRay (package_pushed, package_deleted) or a dry-run preview (dry_run_package_push, dry_run_package_delete).
  • Logs are operational: feed cycle, connectivity, startup mode, errors, and no-ops (already pushed, does not exist, skipped).

-o json (or --output json) is an explicit request for machine output, so it prints only the result events, as JSONL on stdout, and nothing else: every log is suppressed. No 2>/dev/null needed.

safedep integration jfrog run -o json
{"event":"package_pushed","report_id":"01KR0EKN...","package":"make-array","ecosystem":"npm","versions":["0.1.2"],"issue_id":"SD-01KR0EKN...","status":201}
{"event":"package_deleted","report_id":"01KR0G12...","package":"retracted","ecosystem":"pypi","issue_id":"SD-01KR0G12...","status":200}

Without -o json, the command prints for humans: results and logs both render to stderr, unchanged from before, except the high-frequency no-ops (already pushed, does not exist) are now dimmed but always shown (no --verbose needed).

Mode Output events
Real run package_pushed, package_deleted
Dry run dry_run_package_push, dry_run_package_delete

Design (addressing review)

  • Output vs logs. A single reporter (reporter.go) routes everything by output mode. Only results reach stdout; everything operational is a log. Under -o json logs are suppressed entirely, so the json stream is results-only and stderr stays empty.
  • Constructor DI. The reporter is a constructor dependency of all four components (feed service, feed source, real client, print client), so wiring is uniform. No post-construction field assignment.
  • Token flag renamed to --insecure-instance-access-token: a token on the command line leaks into shell history and the process list. Docs lead with the environment variable and never show a literal token. (Follows the existing --insecure-keychain-fallback convention.)
  • The corrupt-cursor recovery moved to dry/log (internal diagnostic), keeping it out of the json stream.

Fatal errors

A fatal error (JFrog connectivity failure, missing add-on, bad API key) is a returned error, not a log: the command exits non-zero and prints the error, in every mode including -o json (stdout stays clean, so an agent sees empty stdout + non-zero exit). Transient per-cycle errors are logs and the loop retries.

Tests / docs

Tests assert the split: under -o json only state changes and dry-run previews reach stdout and stderr is empty; no-ops/errors/skips are suppressed. Full go test ./..., gofmt, and cobra convention tests green. docs/cmd/integration-jfrog-run.md and docs/integration-jfrog.md document the output/logs boundary and the flag.

@safedep

safedep Bot commented Aug 26, 2026

Copy link
Copy Markdown

SafeDep Report Summary

Green Malicious Packages Badge Green Vulnerable Packages Badge Green Risky License Badge

No dependency changes detected. Nothing to scan.

View complete scan results →

This report is generated by SafeDep GitHub App

@KunalSin9h
KunalSin9h force-pushed the feat/jfrog-json-output branch 6 times, most recently from faa7187 to 2696320 Compare August 26, 2026 09:47
arunanshub
arunanshub previously approved these changes Aug 26, 2026
Comment thread internal/cmd/integration/jfrog/run.go Outdated
Comment thread internal/cmd/integration/jfrog/run.go Outdated
Comment thread internal/cmd/integration/jfrog/run.go Outdated
Comment thread docs/cmd/integration-jfrog-run.md Outdated
@KunalSin9h
KunalSin9h force-pushed the feat/jfrog-json-output branch from 2696320 to 50341d4 Compare August 26, 2026 12:20
@KunalSin9h KunalSin9h changed the title feat(integration-jfrog): add -o json JSONL output for the feed daemon feat(integration-jfrog): add -o json output, separated from logs Aug 26, 2026
@KunalSin9h
KunalSin9h force-pushed the feat/jfrog-json-output branch 6 times, most recently from e21306a to feccacb Compare August 26, 2026 14:00
The run daemon separates output from logs. A single reporter (reporter.go),
injected into every component, routes each line by output mode:

- Output: a real state change in XRay (package_pushed, package_deleted) or a
  dry-run preview (dry_run_package_push, dry_run_package_delete).
- Logs: everything operational (feed cycle, connectivity, startup mode,
  errors, no-ops, skips).

Under -o json the reporter prints only result events, as JSONL on stdout, and
suppresses every log: the json stream is results only, nothing on stderr. In
any other mode nothing goes to stdout and results and logs render as drytui
lines on stderr, the same as the rest of the CLI. The two per-package no-ops
(already pushed, does not exist) are dimmed but always shown in human modes.

The reporter is a constructor dependency of all four components, so wiring is
uniform.

Also rename the token flag to --insecure-instance-access-token: a token on
the command line is saved in the shell history and shown in the process list.
The docs lead with the environment variable and never show a literal token.

Docs and comments for this change are written in simple, plain English.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RS4e9U1L2dP4H5XXeGPe6y
@KunalSin9h
KunalSin9h force-pushed the feat/jfrog-json-output branch from feccacb to 4b224ad Compare August 26, 2026 14:04
@KunalSin9h
KunalSin9h merged commit 70a1b07 into main Aug 26, 2026
6 checks passed
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.

4 participants