facebook / facebook-nodejs-business-sdk

Node.js SDK for Meta Marketing APIs
https://developers.facebook.com/docs/business-sdk
Other
489 stars 226 forks source link

Not receiving specific errors when calling #262

Closed dtsehl closed 10 months ago

dtsehl commented 1 year ago

Which SDK version are you using?

17.0.3

What's the issue?

We are not receiving any error codes, specific errors or anything similar when calling various endpoints, so we cannot debug what an error might be when we send a call. We are only receiving a generic FacebookRequestError.

Steps/Sample code to reproduce the issue

try {
                await this.init(access_token);
                const savedAudience = new bizSdk.SavedAudience(audienceId);
                const result = await savedAudience.read(
                    fields,
                );
                return result;
} catch (error) {
  console.error(error);
}

Observed Results:

We are receiving this error response back when making the call:

  "name": "FacebookRequestError",
  "stack": "Error\n    at FacebookRequestError.FacebookError ... at new FacebookRequestError ...
  "method": "GET",
  "url": "https://graph.facebook.com/v17.0/act_correctAccountNumber/saved_audiences?fields=id%2Cname&access_token=correct_token",
  "data": {}
}

Expected Results:

We expect a more verbose error back other than a generic FacebookRequestError, so that we can debug what the issue is.

For example:

{
    "message": "Application does not have permission for this action",
    "type": "OAuthException",
    "code": 10,
    "error_subcode": 2446325,
    "is_transient": false,
    "error_user_title": "Business Account Not Allowed to Advertise",
    "error_user_msg": "This business account didn't comply with our Advertising Policies or other standards.",
  }
krishna-koushik commented 1 year ago

+1

simonbrunel commented 11 months ago

Same issue, fixed by downgrading to v17.0.2 so most probably introduced by this commit.

@stcheng Would you be able to have a look at it?

stcheng commented 11 months ago

will take a look. if no short term feasible solutions, i would probably do a git revert on this specific commit. thanks for reporting this.

ahmtakf commented 11 months ago

You should debug "constructErrorResponse" method and see what fields axios response returns. You return undefined because you do not construct from the correct fields on version 18.0.1.

aaronhayes commented 11 months ago

@stcheng have you had a chance to debug this one yet?

stcheng commented 11 months ago

working on a fix; will update soon.

aaronhayes commented 11 months ago

Thanks!

stcheng commented 11 months ago

anyone please help verify if this issue has been properly addressed and if that is the case i'll tag a new version thank you all

stcheng commented 10 months ago

closing this as addressed in v18.0.2.

krishna-koushik commented 10 months ago

Sorry for the late reply. I am able to confirm that the fix worked on v18.0.2. Thank you :)

stcheng commented 10 months ago

@krishna-koushik no worries. thanks for confirming this.

sebrichards commented 9 months ago

Hey @stcheng thanks for the fix, but why wasn't this backported to v17 given it's still in the support period?