You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From digging into the gem's code in lib/docspring/api_client.rb, I suspect there might be a bug in the error handling. The error response should have been {"status"=>"error", "errors"=>{"submission_data_requests"=>["is invalid"]}} ( which is still a fairly unhelpful error). However the error handling checks if the response_json['errors'] is_a? Array - its not its a hash; and it checks for the existence of response_json['error'] - which doesn't because the key in the response is called errors not error
since it doesn't find an error message even thought it exists, it instead sends a default message of [Could not parse errors from response body]. Here's the full method code
def call_api(http_method, path, opts = {})
request = build_request(http_method, path, opts)
response = request.run
if @config.debugging
@config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
end
unless response.success?
if response.timed_out?
fail ApiError.new('Connection timed out')
elsif response.code == 0
# Errors from libcurl will be made visible here
fail ApiError.new(:code => 0,
:message => response.return_message)
else
exception_message = nil
response_json = JSON.parse(response.body) rescue nil
if response_json.is_a? Hash
if response_json['errors'].is_a? Array
response_errors = response_json['errors'].join(', ')
elsif response_json['error']
response_errors = response_json['error']
end
if response_errors
exception_message = "#{response.status_message}: #{response_errors}"
end
end
unless exception_message
exception_message = "#{response.status_message}: [Could not parse errors from response body]"
end
fail ApiError.new(:code => response.code,
:response_headers => response.headers,
:response_body => response.body),
exception_message
end
end
if opts[:return_type]
data = deserialize(response, opts[:return_type])
else
data = nil
end
return data, response.code, response.headers
end
Could we get proper errors for the future? I also was getting an error for every submission last week because our free trial had ended, but the API provided exactly zero errors or indication of what the issue was. Let me know if I can provide any more info
The text was updated successfully, but these errors were encountered:
I'm trying to create a data request object. I have this code
and it properly creates the response with the pdf
however when I add a key for the data request like below, I get a fatal error
DocSpring::ApiError (: [Could not parse errors from response body]):
From digging into the gem's code in
lib/docspring/api_client.rb
, I suspect there might be a bug in the error handling. The error response should have been{"status"=>"error", "errors"=>{"submission_data_requests"=>["is invalid"]}}
( which is still a fairly unhelpful error). However the error handling checks if theresponse_json['errors'] is_a? Array
- its not its a hash; and it checks for the existence ofresponse_json['error']
- which doesn't because the key in the response is callederrors
noterror
since it doesn't find an error message even thought it exists, it instead sends a default message of
[Could not parse errors from response body]
. Here's the full method codeCould we get proper errors for the future? I also was getting an error for every submission last week because our free trial had ended, but the API provided exactly zero errors or indication of what the issue was. Let me know if I can provide any more info
The text was updated successfully, but these errors were encountered: