镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Ruby exceptions hide error messages #533

Description

@bpo

Version info

  • intercom-ruby version: intercom-4.0.1
  • Ruby version: 2.6.6

Expected behavior

Exception objects raised by the Intercom client should include the error message, as are surfaced by the API. For example, this is a possible API response body associated with a 403 Forbidden response code. The message is very important to understanding why the action is forbidden:

{"type":"error.list","request_id":"xxx","errors":[{"code":"action_forbidden","message":"This user is unsubscribed from emails"}]}"

Actual behavior

The Ruby client masks all details of the error returned by the API, and surfaces only a blank Ruby object that can be used to guess the return code, but not the message:

#Intercom::AuthenticationError:Forbidden @http_code=nil @application_error_code=nil @field=nil @request_id=nil

Steps to reproduce

  1. Trigger any 40x or 50x response from the API

Additional details

It looks like the client was designed to parse these error messages properly in raise_application_errors_on_failure, but most non-20x response codes will abort client handling early in raise_errors_on_failure

Activity

  1. changed the title [-]Ruby exceptions hide all error details[/-] [+]Ruby exceptions hide error messages[/+] on Jul 11, 2020
  2. theandrewykim commented on Oct 28, 2020

    @theandrewykim
    Contributor

    @bpo merged a change in: #548

    That should reveal more of our verbose error messages

  3. rahulgdsouza commented on Oct 30, 2020

    @rahulgdsouza
    Contributor

    Reopening issue as we had to revert #548

  4. bpo commented on Nov 2, 2021

    @bpo
    Author

    Intercom's API may reply with a response that looks like this:

    {"type"=>"error.list", "request_id"=>"xxxxx", "errors"=>[{"code"=>"action_forbidden", "message"=>"An email to this user has hard bounced and they cannot be messaged via email"}]}
    

    As noted above this will raise an Intercom::AuthenticationError with no information other than the message "Forbidden".

    With the patch from #548 applied the raised error will instead be:

    Intercom::UnexpectedError (The error of type '' is not recognized. It occurred with the message: An email to this user has hard bounced and they cannot be messaged via email and http_code: '403'. Please contact Intercom with these details.)
    

    This is caused by two separate issues not addressed in #548:

    • Error code action_forbidden is not supported in this client
    • The client's error-handling fallthrough (message_for_unexpected_error_with_type) expects errors to have a type field where the current API uses a code field.

    The workaround for a codebase I maintain was to refine the behaviors of raise_errors_on_failure and raise_application_errors_on_failure pending support for this gem from Intercom.

  5. johnlempka commented on Jul 11, 2022

    @johnlempka

    This still seems to be happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions