Spectral Github Action passes even when Spectral has an error
We use this Github Action to validate our OpenAPI specs. If API spec we're validating isn't a valid OpenAPI spec, spectral will fail but the github action will still pass.
Context
We use Spectral in several places to enforce and report on compliance with internal API standards. This bug has allowed invalid API specs to be committed, which has broken our reporting pipelines and could introduce unexpected issues in prod.
Current Behavior
The Github action ran, analyzed the first of several API specs with no issue, and then on the second one emitted Error: Cannot read properties of null (reading 'type') and reported the GHA as successful.
Expected Behavior
I would expect the Github action to fail if Spectral experiences an error.
Possible Workaround/Solution
We found and fixed the API spec with the typo.
Steps to Reproduce
- Create a valid OpenAPI spec with the following invalid block (empty enum value):
servers:
- description: SwaggerHub API Auto Mocking
url: https://virtserver.swaggerhub.com/Organization/ApiName/v1.7
# 1. Production Environment
- url: 'https://api/.{domain}/path'
description: 'Description'
variables:
domain:
default: 'domain.one'
enum:
- 'domain.one'
- 'domain.two'
-
- Analyze it with the github action
- Spectral should fail but the GHA will still pass.
Environment
- Version used: v0.8.13@6416fd0
- Environment name and version (e.g. Chrome 39, node.js 5.4): Node.js 20.19.5
- Operating System and version (desktop or mobile): Ubuntu 24.04, Docker 28.0.4
- Link to your environment/workspace/project: private self-hosted GHA runner
@ross-bragg-sonarsource sorry for the long wait on this - our team is looking into the issue.
If you already have a configured environment, could you check whether the problem also occurs with version 0.8.12? Confirming this would help us with the investigation and speed up the fix.
Thanks for your patience!