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

Skip to content

Fix/logs help default command#3252

Merged
saikonen merged 3 commits into
Netflix:masterfrom
LuisJG8:fix/logs-help-default-command
Jun 18, 2026
Merged

Fix/logs help default command#3252
saikonen merged 3 commits into
Netflix:masterfrom
LuisJG8:fix/logs-help-default-command

Conversation

@LuisJG8

@LuisJG8 LuisJG8 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

PR Type

  • Bug fix

Summary

Fix logs --help so it shows only the logs group help instead of also falling through to the default logs show command help.

Issue

Fixes #3251

Reproduction

Runtime: local

Commands to run:

PYTHONPATH=. python metaflow/tutorials/00-helloworld/helloworld.py logs --help
PYTHONPATH=. python metaflow/tutorials/00-helloworld/helloworld.py logs show --help

Where evidence shows up: parent console

Before (error / log snippet)
Usage: helloworld.py logs [OPTIONS] COMMAND [ARGS]...

  Commands related to logs

Options:
  --help  Show this message and exit.

Commands:
  scrub           Scrub stdout/stderr produced by a task or all tasks in a
                  step.

  show [Default]  Show stdout/stderr produced by a task or all tasks in a
                  step.
Usage: helloworld.py logs show [OPTIONS] INPUT_PATH

  Show stdout/stderr produced by a task or all tasks in a step.
After (evidence that fix works)
Usage: helloworld.py logs [OPTIONS] COMMAND [ARGS]...

  Commands related to logs

Options:
  --help  Show this message and exit.

Commands:
  scrub           Scrub stdout/stderr produced by a task or all tasks in a
                  step.

  show [Default]  Show stdout/stderr produced by a task or all tasks in a
                  step.

Root Cause

logs uses a custom CustomGroup to preserve backward compatibility for legacy invocations such as logs , treating them as logs show .

The fallback logic in CustomGroup.parse_args() was too broad. It first attempted to parse the provided args, and if parsing consumed the argument list or failed, it retried with the default command inserted. Group-level help is handled by Click during parsing, so logs --help could be treated like a fallback case and append logs show --help output after the group help.

Why This Fix Is Correct

The fix handles group-level help before default-command fallback. This restores the expected Click invariant:

logs --help shows group help.
logs show --help shows subcommand help.
logs still routes to the default show command.
The change is minimal because it stays inside the existing CustomGroup.parse_args() compatibility layer and does not change datastore, log loading, or command behavior outside argument parsing.

Failure Modes Considered

The fix handles group-level help before default-command fallback. This restores the expected Click invariant:

logs --help shows group help.
logs show --help shows subcommand help.
logs still routes to the default show command.

Tests

  • Unit tests added/updated
  • Reproduction script provided (required for Core Runtime)
  • CI passes
  • If tests are impractical: explain why below and provide manual evidence above

Non-Goals

This PR does not change log retrieval, log scrubbing, datastore behavior, or the existing default-command design for logs.

AI Tool Usage

  • AI tools were used

GPT-5.5

AI tools were used to inspect the relevant CLI code, propose the minimal parser fix, and draft tests. I reviewed the generated changes and verified them locally with focused unit tests and manual CLI checks.

@greptile-apps

greptile-apps Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Fixes logs --help bleeding into logs show --help output by re-raising click.exceptions.Exit in CustomGroup.parse_args, preventing Click's help-processing path from being swallowed and retried with the default subcommand prepended.

  • parse_args refactor: re-raises click.exceptions.Exit so --help (and any other ctx.exit() call) terminates cleanly; returns early on successful first parse, eliminating the prior double-parse on every successful invocation.
  • Empty-args handling: moved to an explicit early-return branch, keeping the same routing behaviour (logs with no args → logs show with no args).
  • Tests added: covers --help isolation, show --help, bare-pathspec fallback, and the option-forwarding fallback path (--stdout 123/start/1).

Confidence Score: 5/5

Safe to merge — the change is a self-contained fix inside the existing parse_args compatibility shim with no impact on log retrieval, datastore, or any other command path.

The fix correctly re-raises click.exceptions.Exit so Click's own help machinery is never swallowed, and returns early on a successful first parse to avoid the previous double-parse on every normal invocation. All three backward-compat paths (help, explicit subcommand, bare pathspec/option forwarding) are exercised by the new tests.

No files require special attention.

Important Files Changed

Filename Overview
metaflow/plugins/logs_cli.py Refactored CustomGroup.parse_args to re-raise click.exceptions.Exit (fixing --help bleed-through) and return early on successful parse; logic is correct and minimal
test/unit/test_logs_cli.py New unit test file covering --help isolation, show --help, plain pathspec fallback, and option-forwarding fallback via parametrize

Reviews (5): Last reviewed commit: "test: use pytest-mock for logs CLI routi..." | Re-trigger Greptile

Comment thread metaflow/plugins/logs_cli.py Outdated
Comment thread test/unit/test_logs_cli.py Outdated
@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (master@08b7218). Learn more about missing BASE report.

Files with missing lines Patch % Lines
metaflow/plugins/logs_cli.py 66.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master    #3252   +/-   ##
=========================================
  Coverage          ?   29.99%           
=========================================
  Files             ?      381           
  Lines             ?    52467           
  Branches          ?     9260           
=========================================
  Hits              ?    15735           
  Misses            ?    35584           
  Partials          ?     1148           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@LuisJG8 LuisJG8 force-pushed the fix/logs-help-default-command branch from 86b42ec to 0eb1e3c Compare June 9, 2026 10:19
@LuisJG8 LuisJG8 force-pushed the fix/logs-help-default-command branch from 1e1b0cc to 3e7e139 Compare June 9, 2026 10:42
@saikonen saikonen merged commit 0ed4821 into Netflix:master Jun 18, 2026
42 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.

logs --help falls through to logs show help

2 participants