Skip to content

Markdown fail-fast workflow does not preserve filename boundaries #8787

Description

@pellared

Description

The fail-fast Markdown workflow does not preserve changed-file boundaries when it passes filenames to the linter.

markdown-fail-fast.yml reads newline-delimited paths from git diff --name-only, flattens them into one whitespace-delimited string with tr/xargs, writes that string to a job output, and passes it to the Docker action's args input. The action image's entrypoint deliberately expands $@ without quotes, so the value is split on whitespace again. A valid Markdown filename containing spaces is consequently interpreted as multiple linter arguments. A repository-root filename beginning with - can likewise be mistaken for a linter option instead of a path.

This can make the check lint the wrong inputs, fail on nonexistent paths, or change linter behavior based only on a changed filename.

Open PR #8632 switches the workflow to markdownlint-cli2 and its globs input, so it may address this while modernizing the Markdown tooling. Please include regression coverage for filename boundaries as part of that change or a follow-up.

Environment

  • OS: GitHub-hosted ubuntu-latest
  • Architecture: x86-64
  • Go Version: N/A
  • opentelemetry-go version: 0de413a318cb52629baefb89a1554a905e105aa3

Steps To Reproduce

The following is a safe reproduction of the workflow's filename-to-argument conversion:

mkdir -p docs
touch 'docs/file with spaces.md'
git add -- 'docs/file with spaces.md'

CHANGED=$(git diff --cached --name-only | grep '\.md$' || true)
MD=$(echo "$CHANGED" | tr '\n' ' ' | xargs)

# Model the whitespace-based argv parsing used by the current action.
printf '%s\n' "$MD" | xargs -n1 printf 'argument: <%s>\n'

The output contains three arguments instead of one:

argument: <docs/file>
argument: <with>
argument: <spaces.md>

The same regression can be covered with a workflow/helper test that feeds a path containing spaces and a repository-root path beginning with -, then asserts that each original path reaches the linter as one filename and cannot be reinterpreted as an option.

Expected behavior

Every changed Markdown path should be passed to the linter as exactly one filename, regardless of spaces or option-shaped path components. Filename data should not be parsed as additional command-line syntax.

Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    actionsPull requests that update GitHub action codebugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions