Skip to content

fix: skip metrics submission after fatal generation failure (fixes #2010)#2161

Open
gavin913427-hash wants to merge 2 commits intoasyncapi:masterfrom
gavin913427-hash:fix/metrics-after-failure
Open

fix: skip metrics submission after fatal generation failure (fixes #2010)#2161
gavin913427-hash wants to merge 2 commits intoasyncapi:masterfrom
gavin913427-hash:fix/metrics-after-failure

Conversation

@gavin913427-hash
Copy link
Copy Markdown

What

Skip anonymous metrics submission after a fatal generation failure.

Why

When a generation fails with a fatal error (e.g., non-empty output directory), the CLI was still attempting to submit anonymous metrics in the finally() method. This resulted in additional unrelated errors being printed, which polluted the output and confused users.

How

  • Modified the finally() method in the base command to only submit metrics when there's no error
  • When there's an error, the method now skips metrics submission entirely
  • This prevents secondary errors from being printed after a fatal failure

Changes

File Change
src/apps/cli/internal/base.ts Skip metrics submission in finally() when error is present

Testing

# Before: prints metrics error after generation failure
mkdir out && echo test > out/file.txt
asyncapi generate asyncapi.yaml @asyncapi/html-template --output ./out
# Shows: generation error + metrics submission error

# After: only prints generation failure
asyncapi generate asyncapi.yaml @asyncapi/html-template --output ./out
# Shows: only generation error

Fixes #2010

When a generation fails with a fatal error, the CLI was still attempting
to submit anonymous metrics, which resulted in additional unrelated
errors being printed.

Now metrics are only submitted when there's no error (success case).

Fixes asyncapi#2010
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 3, 2026

🦋 Changeset detected

Latest commit: 3af957a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@asyncapi/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 3, 2026

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

Labels

None yet

Projects

Status: To Triage

Development

Successfully merging this pull request may close these issues.

[BUG] Generator attempts to submit anonymous metrics even after fatal generation failure

1 participant