-
Notifications
You must be signed in to change notification settings - Fork 0
fix: decode API responses before exporting + CI verbosity #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
shreemaan-abhishek
merged 3 commits into
master
from
create-json-decode-and-ci-verbosity
May 26, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
50b7e3b
fix: decode API responses before exporting to avoid yaml byte-array bug
shreemaan-abhishek e0b4bad
ci(e2e): make the suite verbose so it isn't dark for minutes
shreemaan-abhishek 34a72ae
fix(ssl): fail closed when ssl response can't be decoded
shreemaan-abhishek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| package cmdutil | ||
|
shreemaan-abhishek marked this conversation as resolved.
|
||
|
|
||
| import ( | ||
| "bytes" | ||
| "encoding/json" | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "gopkg.in/yaml.v3" | ||
| ) | ||
|
|
||
| func TestExporter_WriteAPIResponse_YAML_DecodesObject(t *testing.T) { | ||
| // The original bug: writing json.RawMessage([]byte) directly to the YAML | ||
| // encoder serialized the bytes as a list of integers instead of a map. | ||
| // WriteAPIResponse must decode first so YAML emits a proper object. | ||
| body := []byte(`{"id":"r1","name":"demo","status":1}`) | ||
|
|
||
| var buf bytes.Buffer | ||
| if err := NewExporter("yaml", &buf).WriteAPIResponse(body); err != nil { | ||
| t.Fatalf("WriteAPIResponse failed: %v", err) | ||
| } | ||
|
|
||
| out := buf.String() | ||
| if strings.HasPrefix(strings.TrimSpace(out), "- ") { | ||
| t.Fatalf("yaml output looks like a byte sequence, not an object: %q", out) | ||
| } | ||
|
|
||
| var decoded map[string]interface{} | ||
| if err := yaml.Unmarshal(buf.Bytes(), &decoded); err != nil { | ||
| t.Fatalf("yaml output is not a valid map: %v (output: %q)", err, out) | ||
| } | ||
| if decoded["id"] != "r1" || decoded["name"] != "demo" { | ||
| t.Fatalf("yaml output missing expected fields: got %v", decoded) | ||
| } | ||
| } | ||
|
|
||
| func TestExporter_WriteAPIResponse_JSON_RoundTripsObject(t *testing.T) { | ||
| body := []byte(`{"id":"r1","name":"demo"}`) | ||
|
|
||
| var buf bytes.Buffer | ||
| if err := NewExporter("json", &buf).WriteAPIResponse(body); err != nil { | ||
| t.Fatalf("WriteAPIResponse failed: %v", err) | ||
| } | ||
|
|
||
| var decoded map[string]interface{} | ||
| if err := json.Unmarshal(buf.Bytes(), &decoded); err != nil { | ||
| t.Fatalf("json output is not a valid object: %v (output: %q)", err, buf.String()) | ||
| } | ||
| if decoded["id"] != "r1" || decoded["name"] != "demo" { | ||
| t.Fatalf("json output missing expected fields: got %v", decoded) | ||
| } | ||
| } | ||
|
|
||
| func TestExporter_WriteAPIResponse_InvalidJSON_ReturnsError(t *testing.T) { | ||
| body := []byte(`not json`) | ||
| err := NewExporter("yaml", &bytes.Buffer{}).WriteAPIResponse(body) | ||
| if err == nil { | ||
| t.Fatal("expected error decoding invalid JSON") | ||
| } | ||
| if !strings.Contains(err.Error(), "failed to decode response") { | ||
| t.Fatalf("error did not mention decoding: %v", err) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.