successfully connecting and parsing data from API
CI / Detect changed paths (pull_request) Successful in 4s
CI / Odin unit tests and build (pull_request) Successful in 1m18s
CI / API unit tests and lint (pull_request) Failing after 1m29s
CI / Infra unit tests, vet, and preview (pull_request) Successful in 1m5s

This commit is contained in:
2026-09-13 16:52:06 -06:00
parent c6bfb966b7
commit cc474b1ab1
+6 -3
View File
@@ -77,27 +77,29 @@ request_json_array :: proc(
) { ) {
resp, req_err := http.http_get(url) resp, req_err := http.http_get(url)
if req_err != nil { if req_err != nil {
log.errorf("failed getting response from API: %w", req_err)
defer free(req_err) defer free(req_err)
return nil, json.Null(nil), api_error(req_err.code, strings.clone(req_err.message)), false return nil, json.Null(nil), api_error(req_err.code, strings.clone(req_err.message)), false
} }
defer delete(resp.body) defer delete(resp.body)
if resp.status != 200 { if resp.status != 200 {
log.errorf("response did not return with 200 => %d", resp.status)
return nil, return nil,
json.Null(nil), json.Null(nil),
api_error(resp.status, strings.clone(strings.trim_space(resp.body))), api_error(resp.status, strings.clone(strings.trim_space(resp.body))),
false false
} }
log.debugf("got %s => %s", url, resp.body)
v, perr := json.parse_string(resp.body) v, perr := json.parse_string(resp.body)
if perr != .None { if perr != .None {
log.errorf("parsing json response failed: %w", perr)
return nil, json.Null(nil), api_error(int(perr), "invalid JSON in API response"), false return nil, json.Null(nil), api_error(int(perr), "invalid JSON in API response"), false
} }
a, is_arr := v.(json.Array) a, is_arr := v.(json.Array)
if !is_arr { if !is_arr {
log.error("API response was not in JSON array format")
json.destroy_value(v) json.destroy_value(v)
return nil, json.Null(nil), api_error(0, "API response was not a JSON array"), false return nil, json.Null(nil), api_error(0, "API response was not a JSON array"), false
} }
@@ -135,13 +137,14 @@ get_catalog_objects :: proc(
) { ) {
sb := strings.builder_make() sb := strings.builder_make()
defer strings.builder_destroy(&sb) defer strings.builder_destroy(&sb)
fmt.sbprintf(&sb, "%s/api/v1/objects?catalog=%s", endpoint(base_url, ""), catalog_name) fmt.sbprintf(&sb, "%s?catalog=%s", endpoint(base_url, "/api/v1/objects"), catalog_name)
if region != "" { if region != "" {
fmt.sbprintf(&sb, "&region=%s", region) fmt.sbprintf(&sb, "&region=%s", region)
} }
fmt.sbprintf(&sb, "&limit=%d", 10_000) fmt.sbprintf(&sb, "&limit=%d", 10_000)
url := strings.to_string(sb) url := strings.to_string(sb)
arr, val, err, ok := request_json_array(url) arr, val, err, ok := request_json_array(url)
if !ok { if !ok {
return nil, err return nil, err