Skip to content

Conversation

@Vombato
Copy link
Collaborator

@Vombato Vombato commented Nov 7, 2025

Fix: Add pipefail and error handling to compilation step

Description

This PR improves error handling in the Slither workflow's compilation step by adding proper bash error handling flags and executing the compile command in a controlled subshell.

Type of Change

  • Bug fix
  • New workflow or feature
  • Documentation update
  • Configuration change
  • Other (please describe):

Related Issue

N/A - Proactive improvement for error handling

Changes Made

.github/workflows/slither.yaml:

  • Added set -euo pipefail before executing compile command
  • Changed direct command execution to bash -eo pipefail -c "$COMPILE_COMMAND"
  • Ensures proper error propagation from compilation failures

What changed:

Before:

run: |
  $COMPILE_COMMAND

After:

run: |
  set -euo pipefail
  bash -eo pipefail -c "$COMPILE_COMMAND"

Why This Matters

Without proper error handling flags:

  • Failed commands in the compilation pipeline might be ignored
  • Undefined variables could cause silent failures
  • Partial pipeline failures (e.g., command1 | command2) wouldn't be detected

With set -euo pipefail:

  • -e: Exit immediately if any command fails
  • -u: Treat undefined variables as errors
  • -o pipefail: Return the exit code of the last failed command in a pipeline

This ensures the workflow fails fast and clearly when compilation issues occur, rather than continuing with potentially broken artifacts.

Testing

  • Tested workflow locally or in a test repository
  • All workflows pass actionlint validation
  • Compilation errors are now properly caught and reported

Additional Context

This change follows shell scripting best practices and aligns with the recent shellcheck warning fixes. It ensures that compilation failures are properly detected and reported, improving the reliability and debuggability of the Slither analysis workflow.

The bash -eo pipefail -c wrapper ensures the flags apply to the entire compile command, even if it's a complex multi-command string.

@Vombato Vombato requested a review from a team as a code owner November 7, 2025 10:26
@Vombato Vombato added the bug Something isn't working label Nov 7, 2025
@Vombato Vombato self-assigned this Nov 7, 2025
@Vombato Vombato requested a review from mikeredmond November 7, 2025 10:27
@mikeredmond mikeredmond merged commit 6a6a603 into main Nov 7, 2025
5 checks passed
@Vombato Vombato deleted the fix/slither-bash-pipefail branch November 7, 2025 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants