Skip to content

Commit

Permalink
Merge pull request #776 from openziti/fix-ziti-error-parsing
Browse files Browse the repository at this point in the history
fix ziti_error parsing
  • Loading branch information
ekoby authored Nov 21, 2024
2 parents d5a7ac5 + 11d17eb commit 9db50a3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion inc_internal/internal_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ XX(err, model_number, none, , __VA_ARGS__) \
XX(http_code, model_number, none, , __VA_ARGS__) \
XX(code, model_string, none, code, __VA_ARGS__) \
XX(message, model_string, none, message, __VA_ARGS__) \
XX(cause, model_string, map, cause, __VA_ARGS__)
XX(cause, json, map, cause, __VA_ARGS__)

#define ZITI_ENROLLMENT_JWT_HEADER_MODEL(XX, ...) \
XX(alg, jwt_sig_method, none, alg, __VA_ARGS__) \
Expand Down
11 changes: 10 additions & 1 deletion library/ziti_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,16 @@ static void ctrl_body_cb(tlsuv_http_req_t *req, char *b, ssize_t len) {
string_buf_free(resp->content_proc);
FREE(resp->content_proc);
} else {
ziti_error_ptr_from_json(&error, json_object_object_get(resp->content, "error"));
json_object *err_json = json_object_object_get(resp->content, "error");
if (err_json) {
error = alloc_ziti_error();
if (ziti_error_from_json(error, err_json) != 0) {
ZITI_LOG(ERROR, "failed to parse ziti_error: %s", json_object_get_string(err_json));
error->err = ZITI_WTF;
error->code = strdup("UNEXPECTED_ERROR");
error->message = strdup(json_object_get_string(err_json));
}
}
resp_meta meta = {0};
resp_meta_from_json(&meta, json_object_object_get(resp->content, "meta"));
json_object *data = json_object_object_get(resp->content, "data");
Expand Down

0 comments on commit 9db50a3

Please sign in to comment.