Skip to content

CI: NATS integration test fails due to version extraction error #833

@corylanou

Description

@corylanou

Problem

The NATS integration test in CI is failing because the NATS CLI version extraction is returning an empty string, resulting in a 404 error when trying to download the CLI binary.

Error

ERROR 404: Not Found

The wget command tries to download from:

https://github.com/nats-io/natscli/releases/download/v/nats--linux-amd64.zip

Notice the version is completely missing: v/ instead of v0.3.0/

Root Cause

File: .github/workflows/commit.yml
Line: 223

NATS_VERSION=$(curl -s https://api.github.com/repos/nats-io/natscli/releases/latest | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/')

This command is failing to extract the version, likely due to:

  1. GitHub API rate limiting - CI may hit rate limits
  2. Transient network issues during API call
  3. Fragile regex pattern that doesn't handle all edge cases

Impact

  • ❌ NATS integration tests fail
  • ✅ All other CI checks pass
  • Not blocking development work on directory-watcher or other features

Recommended Solution

Replace the fragile grep/sed approach with jq for reliable JSON parsing:

# Before (fragile)
NATS_VERSION=$(curl -s https://api.github.com/repos/nats-io/natscli/releases/latest | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/')

# After (robust)
NATS_VERSION=$(curl -s https://api.github.com/repos/nats-io/natscli/releases/latest | jq -r '.tag_name' | sed 's/^v//')
if [ -z "$NATS_VERSION" ]; then
  echo "Failed to get NATS CLI version from GitHub API"
  exit 1
fi

Benefits:

  • jq is pre-installed on GitHub Actions runners
  • Proper JSON parsing instead of regex
  • Error handling to fail fast with clear message
  • More maintainable

Alternative Quick Fix

Temporarily pin the version until the proper fix is implemented:

NATS_VERSION="0.3.0"

Context

Discovered while testing PR #827 (directory-watcher feature). The failure is unrelated to that PR's code changes.

Failing Check: Run NATS Integration Tests
Duration: Fails in ~15 seconds
All Other Checks: Passing ✅

Tasks

  • Update .github/workflows/commit.yml line 223 to use jq
  • Add error handling for version extraction
  • Test the fix in CI
  • Consider if other workflows have similar fragile patterns

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions