Skip to content

Bug Fix: Resolve Error Blocking Local Environment Setup#1557

Open
yashasip wants to merge 1 commit into
zalando:mainfrom
yashasip:bugfix/issue-1498-local-build-error
Open

Bug Fix: Resolve Error Blocking Local Environment Setup#1557
yashasip wants to merge 1 commit into
zalando:mainfrom
yashasip:bugfix/issue-1498-local-build-error

Conversation

@yashasip

@yashasip yashasip commented Mar 6, 2026

Copy link
Copy Markdown

Fix for Issue: #1498

Problem

RestApiViolationsTest.shouldReturn404WhenHostNotRecognised() was failing, causing ./gradlew clean build to break.

The test was asserting two things:

  1. The response status code is 404
  2. The response body message is exactly "Unknown host while retrieving api definition url: remote-localhost"

The second assertion was failing because the error message is environment-sensitive and not guaranteed to be stable.

Root Cause

When a request results in a 404, the error message in the response body varies depending on why the connection failed. There are 3 possible cases:

Case Scenario Message
1 DNS failed to resolve the host Unknown host while retrieving api definition url: remote-localhost
2 DNS resolved, but the server is not running Unknown host while retrieving api definition url: Connection refused
3 DNS resolved, server is running, but endpoint is invalid 404 : "---<EOL>timestamp: "2026-03-06T14:18:26.370+00:00"<EOL>status: 404<EOL>error: "Not Found"<EOL>path: "/"<EOL>" while retrieving api definition url

When this test was originally written, http://remote-localhost/test.yaml was hitting Case 1 (DNS resolution failure). However, today the hostname remote-localhost resolves successfully but the server is unreachable, which means it now hits Case 2, producing a different message and breaking the assertion.

Fix

Removed the response body message assertion, keeping only the status code assertion (404 NOT_FOUND). This is sufficient to validate the behaviour of the endpoint and makes the test resilient to environment-specific message variations.

Alternative Fix (if message assertion is desired)

If you want to keep the message assertion, update the expected value to match the current environment:

"Unknown host while retrieving api definition url: Connection refused"

However, this would remain brittle across different environments and is not recommended.

@yashasip yashasip requested a review from tkrop as a code owner March 6, 2026 13:59
@zalando-robot

Copy link
Copy Markdown

Cannot start a pipeline due to:

No accountable user for this pipeline: no Zalando employee associated to this GitHub username

Click on pipeline status check Details link below for more information.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants