Skip to content

fix: handle json.Unmarshal error in GetTestResult#258

Merged
lbroudoux merged 1 commit intomicrocks:masterfrom
mugiwaraluffy56:fix/get-test-result-unmarshal-error
May 4, 2026
Merged

fix: handle json.Unmarshal error in GetTestResult#258
lbroudoux merged 1 commit intomicrocks:masterfrom
mugiwaraluffy56:fix/get-test-result-unmarshal-error

Conversation

@mugiwaraluffy56
Copy link
Copy Markdown
Contributor

GetTestResult in microcks_client.go called json.Unmarshal but ignored the returned error. every other unmarshal call in the same file checks it, this one didn't.

the problem is that if the api returns something unexpected (an html error page, a rate-limit response, or a not-yet-ready response during startup), json.Unmarshal fails silently and result stays as a zero-value TestResultSummary with Success=false and InProgress=false. the polling loop in cmd/test.go sees inProgress=false, exits immediately, and the user gets a failure with no useful message.

the fix is straightforward: check the error and return it so the caller gets a real error instead of a silent bad result.

also removed the redundant []byte(body) cast since io.ReadAll already returns []byte.

…oring it

Signed-off-by: puneeth_aditya_5656 <myakampuneeth@gmail.com>
@mugiwaraluffy56 mugiwaraluffy56 force-pushed the fix/get-test-result-unmarshal-error branch from 50c1a8e to 68cc46a Compare May 1, 2026 19:31
Copy link
Copy Markdown
Member

@lbroudoux lbroudoux left a comment

Choose a reason for hiding this comment

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

This is a nice catch! Thanks for taking the time to push this one.

@lbroudoux lbroudoux added kind/enhancement New feature or request component/cli go Pull requests that update go code labels May 4, 2026
@lbroudoux lbroudoux added this to the Next milestone May 4, 2026
@lbroudoux lbroudoux merged commit f9f232c into microcks:master May 4, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/cli go Pull requests that update go code kind/enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants