facebook / facebook-ruby-business-sdk

Ruby SDK for Meta Marketing API
https://developers.facebook.com/docs/business-sdk
Other
204 stars 161 forks source link

Adding users to freshly created custom audience returns error (#803) Some of the aliases you requested do not exist: users: #125

Closed jkhulme closed 3 years ago

jkhulme commented 3 years ago

Which SDK version are you using?

9.0.1 (but was seeing the same issue in 8.0.3 and earlier)

What's the issue?

We have a sidekiq worker that creates a custom audience and then adds users to it. On the first run it fails with error (#803) Some of the aliases you requested do not exist: users (our latest fbtrace_id is AwzHWs8cEb1y75r_tiOwMAs) Sidekiq then retries the job, and the worker succeeds, and users are added to our custom audience.

I can't see anything in the docs that suggest there is a lag between when an audience is created and when it is usable, and adding a delay in manually did not fix the issue. I'm stumped by it.

Steps/Sample code to reproduce the issue

audience = FacebookAds::AdAccount.get(account_id).customaudiences.create(
  name: audience_name,
  subtype: 'CUSTOM',
  customer_file_source: 'USER_PROVIDED_ONLY'
)
...
payload = {
  schema: %w[EMAIL_SHA256 PHONE_SHA256],
  data: [...]
}
FacebookAds::CustomAudience.get(audience.id).users.create(payload: payload.to_json)

Observed Results:

When FacebookAds::CustomAudience.get(audience.id).users.create(payload: payload.to_json) is the first time we get an error like FacebookAds::ClientError: (#803) Some of the aliases you requested do not exist: users: (fbtrace_id: AwzHWs8cEb1y75r_tiOwMAs) the job is then retried by sidekiq about 30s later and succeeds.

Expected Results:

It should succeed first time and not need to retry

jkhulme commented 3 years ago

Sorry, seems to have created the issue twice