Conversation
| preReleaseCommand: >- | ||
| pwsh -Command " | ||
| @('app-runner/SentryAppRunner.psd1', 'sentry-api-client/SentryApiClient.psd1') | ForEach-Object { | ||
| (Get-Content $_) -replace \"ModuleVersion = '.*'\", \"ModuleVersion = '$env:CRAFT_NEW_VERSION'\" | Set-Content $_ | ||
| } | ||
| " |
There was a problem hiding this comment.
Bug: The regex in preReleaseCommand for updating ModuleVersion expects a single space, but the target .psd1 files use multiple spaces, causing the version update to fail silently.
Severity: HIGH
Suggested Fix
Update the regex pattern in the preReleaseCommand to account for variable whitespace. Change "ModuleVersion = '.*'" to "ModuleVersion\s+= '.*'" to correctly match the ModuleVersion line regardless of the number of spaces.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: .craft.yml#L4-L9
Potential issue: The `preReleaseCommand` in `.craft.yml` uses a PowerShell `-replace`
command with the pattern `"ModuleVersion = '.*'"` to update the module version. However,
the target `.psd1` files format this line as `ModuleVersion = '1.0.0'` with
multiple spaces for alignment. PowerShell's regex engine requires an exact match, so the
single space in the pattern does not match the multiple spaces in the file. As a result,
the replacement fails silently, and the module version is never updated from the
hardcoded `'1.0.0'`. This will cause all releases to be published with an incorrect,
static version number.
Did we get this right? 👍 / 👎 to inform future reviews.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| preReleaseCommand: >- | ||
| pwsh -Command " | ||
| @('app-runner/SentryAppRunner.psd1', 'sentry-api-client/SentryApiClient.psd1') | ForEach-Object { | ||
| (Get-Content $_) -replace \"ModuleVersion = '.*'\", \"ModuleVersion = '$env:CRAFT_NEW_VERSION'\" | Set-Content $_ |
There was a problem hiding this comment.
Version regex won't match multi-space alignment in manifests
High Severity
The -replace regex pattern ModuleVersion = '.*' expects a single space between ModuleVersion and =, but both .psd1 files use multiple spaces for column alignment (e.g., ModuleVersion = '1.0.0'). The regex won't match, so the preReleaseCommand will silently fail to update the version, and every release will ship with the hardcoded 1.0.0 version.
| @('app-runner/SentryAppRunner.psd1', 'sentry-api-client/SentryApiClient.psd1') | ForEach-Object { | ||
| (Get-Content $_) -replace \"ModuleVersion = '.*'\", \"ModuleVersion = '$env:CRAFT_NEW_VERSION'\" | Set-Content $_ | ||
| } | ||
| " |
There was a problem hiding this comment.
Shell expansion corrupts PowerShell variables in preReleaseCommand
High Severity
The preReleaseCommand wraps the PowerShell script in bash double quotes (pwsh -Command "..."). Since YAML >- block scalars preserve backslashes literally, the \" become escaped quotes in bash, keeping the content inside a double-quoted shell context. This means bash expands $_ (to bash's last argument, not PowerShell's pipeline variable) and $env (likely empty, turning $env:CRAFT_NEW_VERSION into the literal string :CRAFT_NEW_VERSION) before PowerShell ever sees them. The version replacement would silently produce incorrect results.
|
Bots are not happy. |


#skip-changelog