Skip to content

fix: panic on nil type assertion when testing unregistered service#453

Merged
Harsh4902 merged 1 commit into
microcks:masterfrom
Syedowais312:fix/panic-on-unknown-service-test
Jun 19, 2026
Merged

fix: panic on nil type assertion when testing unregistered service#453
Harsh4902 merged 1 commit into
microcks:masterfrom
Syedowais312:fix/panic-on-unknown-service-test

Conversation

@Syedowais312

@Syedowais312 Syedowais312 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Problem

Running microcks test against a service that isn't registered in Microcks
causes a panic instead of a clean error:

panic: interface conversion: interface {} is nil, not string

This happens in CreateTestResult because the server returns a non-201
response (with no "id" field) when the service is unknown, and the code
does a bare type assertion createTestResp["id"].(string) without checking
the HTTP status first.

Fix

  • Check resp.StatusCode before attempting to parse the response body.
    If it's not 201, return a descriptive error including the HTTP status,
    server message, and service name.
  • Replace the bare type assertion with a comma-ok check as a second
    line of defense.
  • Replace panic(err.Error()) on io.ReadAll with a proper error return.

Before

Screenshot from 2026-06-11 02-25-57

After

Screenshot from 2026-06-11 02-26-12

Fixes: #454

@Vaishnav88sk

Copy link
Copy Markdown

Please pass DCO

@Syedowais312

Copy link
Copy Markdown
Contributor Author

Ooh I forgot to do that 😅

…stResult

Signed-off-by: syedowais312 <syedowais312sf@gmail.com>
@Syedowais312 Syedowais312 force-pushed the fix/panic-on-unknown-service-test branch from b451e2e to 7a16b17 Compare June 10, 2026 21:25
@Syedowais312

Copy link
Copy Markdown
Contributor Author

Please pass DCO

Yup Done.

@Harsh4902 Harsh4902 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GTG. Thanks @Syedowais312 :)

@Harsh4902 Harsh4902 merged commit d63b649 into microcks:master Jun 19, 2026
5 checks passed
@Syedowais312 Syedowais312 deleted the fix/panic-on-unknown-service-test branch June 19, 2026 14:30
@sparshgupta001

Copy link
Copy Markdown

nice work @Syedowais312

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

panic: nil type assertion in CreateTestResult when service is not registered

4 participants