Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(github): add structured versions host logs#10256

Merged
jdx merged 2 commits into
mainfrom
fix/versions-host-structured-logging
Jun 6, 2026
Merged

fix(github): add structured versions host logs#10256
jdx merged 2 commits into
mainfrom
fix/versions-host-structured-logging

Conversation

@jdx

@jdx jdx commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • add logfmt-style structured fields for mise-versions version-list, GitHub release, GitHub attestation, and install-tracking calls
  • log stable endpoint, tool/repo/tag/digest, outcome, status, and fallback fields for successes and fallback paths
  • preserve existing fallback behavior while making non-404 failures easier to inspect from debug/warn logs

Tests

  • cargo test -q versions_host
  • cargo clippy --all-features --all-targets -- -D warnings

Note: This PR was generated by an AI coding assistant.


Note

Low Risk
Observability-only changes in versions-host HTTP paths; fallbacks and error handling are preserved, with safer logging for credentials in full URLs.

Overview
Adds structured, logfmt-style tracing for all mise-versions (versions_host) traffic so debug/warn logs are easier to filter and correlate.

A shared VersionsHostLogContext now drives logs for version list, GitHub release, GitHub attestations, and install tracking, emitting stable fields (endpoint, tool/repo/tag/digest/full/version, outcome, status, fallback, counts where relevant). Values with spaces are quoted; full URLs are sanitized (credentials, query, fragment stripped) before logging.

Ad-hoc warn!/trace! strings are replaced on success and fallback paths (disabled, cache hit, 404, 429, empty, validation failures, etc.). Runtime behavior is unchanged: same fallbacks and error propagation (e.g. version-list still returns Err on non-404 failures; optional JSON fetches still return None).

Unit tests cover log field formatting and URL redaction.

Reviewed by Cursor Bugbot for commit d3fb9fa. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Chores

    • Improved structured logging and tracing for versions-host interactions, install tracking, and release/attestation fetches for clearer diagnostics.
    • More consistent handling of missing or rate-limited release/attestation data with graceful fallbacks and clearer warnings for invalid or mismatched release metadata.
  • Tests

    • Added unit tests for log field rendering and redaction of sensitive URL information.

@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds VersionsHostLogContext and replaces ad-hoc trace/warn messages with structured, context-rich logs across list_versions, fetch_optional_json, github_release, github_attestations, and install tracking; includes tests for field rendering and URL redaction.

Changes

Versions-host structured logging

Layer / File(s) Summary
Logging context type and helpers
src/versions_host.rs
Adds VersionsHostLogContext with fields() and helper logging functions; integrates initial disabled-mode structured logging in list_versions.
Cache, disabled, and rate handling
src/versions_host.rs
list_versions logs disabled-mode entry, cache hits (with counts), and rate-limited skips using the context.
HTTP status handling and result logging
src/versions_host.rs
list_versions now emits structured logs for 404/429 fallbacks, other HTTP failures, empty results, and successful fetches.
GitHub release validation
src/versions_host.rs
github_release uses fetch_optional_json with context, validates asset URLs and tag matching, and logs structured warnings for invalid assets or mismatches.
GitHub attestations fetch
src/versions_host.rs
github_attestations uses fetch_optional_json with context and logs success traces including attestation counts.
Shared optional JSON fetch helper
src/versions_host.rs
fetch_optional_json accepts VersionsHostLogContext and logs 404 as trace, 429 as warn, and other failures while returning Ok(None) for non-fatal cases.
Installation tracking structured logging
src/versions_host.rs
track_install_async replaced ad-hoc trace messages with context-aware structured logs for success, unknown status, and errors.
Context field formatting tests
src/versions_host.rs
Unit tests ensure VersionsHostLogContext::fields() quotes tool names with spaces and redacts credentials in full URL values.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • jdx/mise#10254: Overlaps on refactoring github_release/github_attestations and the shared fetch helper to adjust fallback and warn behavior with VersionsHostLogContext.
  • jdx/mise#10240: Related changes touching GitHub asset URL validation and repo-segment matching used by github_release.

Poem

🐰 With whiskers on the log’s new thread,

I hop through traces, warnings said.
Fields tidy, secrets tucked away,
Versions sing in structured play.
A rabbit cheers — the logs are gay!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding structured logging with logfmt-style fields to versions_host.rs to replace free-form messages.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/versions-host-structured-logging

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/versions_host.rs`:
- Around line 124-133: The struct is including the raw `full` backend URL which
can leak credentials; update the code to never log raw `full` by redacting or
omitting userinfo and query/fragment parts before it's stored or logged.
Specifically, in the factory `install_track(tool: &str, full: &str, version:
&str) -> Self` stop assigning the raw `full` into the struct — instead pass a
sanitized value (or None) produced by a small sanitizer that strips userinfo
(user:pass@), query (`?...`) and fragment (`#...`) from the URL; and apply the
same sanitizer at every place where `full` is included in structured logs or
serialized (the other occurrences that currently log `full`) so logs only
contain the redacted URL or no URL at all.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e5ae067c-18ee-43c8-95a8-7062564d2932

📥 Commits

Reviewing files that changed from the base of the PR and between 7560333 and 3a5b147.

📒 Files selected for processing (1)
  • src/versions_host.rs

Comment thread src/versions_host.rs
@greptile-apps

greptile-apps Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR replaces free-form trace/warn messages in versions_host.rs with structured logfmt-style output via a shared VersionsHostLogContext type and two thin helpers (log_versions_host_trace / log_versions_host_warn). Credential-sensitive full values are sanitized before logging through sanitize_full_for_log, and values containing whitespace or special characters are quoted via Rust's Debug format.

  • Structured fields (endpoint, tool, repo, tag, digest, full, version, outcome, status, fallback, error) now appear consistently across version-list, GitHub release, GitHub attestation, and install-tracking call sites.
  • Two new unit tests verify that values with spaces are quoted and that URL credentials are stripped from full before the field reaches the log.

Confidence Score: 5/5

Observability-only change; no HTTP, caching, or fallback logic is altered.

Every changed line is a log statement replacement or the new helpers/context struct that back them. Runtime outcomes (what gets returned, what gets propagated as an error) are identical to the original code. The only non-obvious logic — credential sanitization in sanitize_full_for_log — is covered by a dedicated unit test. No data paths, API calls, or fallback decisions were modified.

No files require special attention.

Important Files Changed

Filename Overview
src/versions_host.rs Adds structured logfmt-style logging context for all versions-host interactions; introduces VersionsHostLogContext, log_value (with Rust Debug quoting), sanitize_full_for_log (credential stripping), and two thin trace/warn helpers. Runtime control-flow is unchanged.

Reviews (2): Last reviewed commit: "fix(github): redact versions host struct..." | Re-trigger Greptile

Comment thread src/versions_host.rs Outdated
@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown

Hyperfine Performance

mise x -- echo

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.6.0 x -- echo 17.2 ± 0.8 15.6 21.1 1.00
mise x -- echo 17.9 ± 1.5 16.3 41.2 1.04 ± 0.10

mise env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.6.0 env 17.1 ± 0.8 15.5 20.4 1.00
mise env 17.7 ± 0.8 16.3 21.9 1.03 ± 0.07

mise hook-env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.6.0 hook-env 17.9 ± 0.8 16.2 21.0 1.00
mise hook-env 18.3 ± 0.7 16.7 21.4 1.02 ± 0.06

mise ls

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2026.6.0 ls 14.2 ± 0.7 12.9 18.6 1.00
mise ls 14.8 ± 0.7 13.3 18.4 1.04 ± 0.07

xtasks/test/perf

Command mise-2026.6.0 mise Variance
install (cached) 128ms 131ms -2%
ls (cached) 57ms 59ms -3%
bin-paths (cached) 62ms 63ms -1%
task-ls (cached) 122ms 123ms +0%

@jdx jdx merged commit 6a9028c into main Jun 6, 2026
34 checks passed
@jdx jdx deleted the fix/versions-host-structured-logging branch June 6, 2026 22:12
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