Skip to content

fix(artifacts): Support glob patterns and validate all configured patterns match#748

Merged
BYK merged 5 commits intomasterfrom
fix/artifact-glob-pattern-validation
Feb 11, 2026
Merged

fix(artifacts): Support glob patterns and validate all configured patterns match#748
BYK merged 5 commits intomasterfrom
fix/artifact-glob-pattern-validation

Conversation

@BYK
Copy link
Member

@BYK BYK commented Feb 11, 2026

Summary

Fixes a class of silent misconfiguration bugs in artifact pattern matching, motivated by getsentry/cli#230 where 'sentry-*' in .craft.yml was silently treated as an exact match for the literal string "sentry-*" instead of matching "sentry-linux-x64" etc.

Changes

Glob pattern support (src/utils/filters.ts):

  • patternToRegexp() now supports glob wildcards: * maps to .*, ? maps to . in regex
  • Plain strings and /regex/ syntax remain unchanged
  • New globToRegex() helper function

All-patterns-must-match validation (src/artifact_providers/github.ts):

  • New validateAllPatternsMatched() method ensures every configured workflow pattern matched at least one workflow run, and every artifact pattern matched at least one artifact
  • Runs after the existing retry/polling loop succeeds — "wait for CI" behavior is preserved
  • Error messages include available workflow/artifact names for easy debugging
  • Reports all mismatches at once

Publish-level safeguard (src/commands/publish.ts):

  • When artifactProvider.config.artifacts is set but zero artifacts are found, reportError() stops the publish early instead of proceeding to targets that will individually fail with confusing messages

Backward Compatibility

  • Plain strings without * or ?: behavior unchanged (exact match)
  • /regex/ syntax: behavior unchanged
  • Strings with * or ?: previously silently wrong (escaped the chars), now correctly treated as globs — this is a bugfix
  • Legacy SHA-based artifact lookup: completely unaffected

Refs: getsentry/cli#230

…terns match

patternToRegexp() silently escaped glob characters (* and ?), treating
"sentry-*" as an exact match for the literal string "sentry-*" instead
of matching "sentry-linux-x64" etc. This caused getsentry/cli#230 where
a release shipped without platform binaries.

Add first-class glob support: * maps to .* and ? maps to . in regex.
Plain strings and /regex/ syntax remain unchanged.

Add validation in doListArtifactsWithFilters() that every configured
workflow pattern matched at least one workflow run, and every artifact
pattern matched at least one artifact. This catches misconfigurations
early with clear error messages listing available names, instead of
letting them surface as confusing per-target failures.

Add a belt-and-suspenders check in publishMain() that errors when
artifact filters are configured but zero artifacts are found.
@BYK BYK marked this pull request as ready for review February 11, 2026 01:12
Address PR review feedback to use a more idiomatic check.
@BYK
Copy link
Member Author

BYK commented Feb 11, 2026

Addressed the review feedback in e19fc46 — switched from .filter().length === 0 to !allRuns.some() for a more idiomatic check.

…rkflow

Address Cursor BugBot feedback:
- validateAllPatternsMatched now returns errors instead of throwing,
  allowing the retry loop to retry when not all patterns match yet
  (e.g. due to API propagation delay)
- Artifact pattern checks are now scoped to runs matching the filter's
  workflow pattern, preventing cross-workflow false positives
…ests

Avoid conditionals in test assertions — use workflow!.test() instead
of workflow?.test() to make it explicit that workflow is expected to
be defined.
Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

The belt-and-suspenders check in publishMain() was dead code:
printRevisionSummary() already calls listArtifactsForRevision() which
triggers the provider's validation. If that throws, execution stops
before this check; if it succeeds, the cached result is non-empty.
@BYK BYK merged commit 5c870b0 into master Feb 11, 2026
16 checks passed
@BYK BYK deleted the fix/artifact-glob-pattern-validation branch February 11, 2026 16:06
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