Skip to content

Commit

Permalink
Update error handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
askarpets committed May 21, 2024
1 parent b15cf3c commit 333ee0f
Showing 1 changed file with 40 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,47 @@ definitions:
refresh_token: "{{ config.get('credentials', {}).get('refresh_token', config['refresh_token']) }}"
token_refresh_endpoint: "https://api.pinterest.com/v5/oauth/token"

# Error handlers
base_error_handler:
type: DefaultErrorHandler
backoff_strategies:
- type: WaitTimeFromHeader
header: "X-RateLimit-Reset"
response_filters:
- type: HttpResponseFilter
action: IGNORE
error_message: "Max rate limit exceeded"
predicate: "{{ response.get('code') == 8 }}"
- type: HttpResponseFilter
action: IGNORE
error_message: "Can't access catalog product groups because there is no existing catalog."
http_codes: [409]
- type: HttpResponseFilter
action: FAIL
error_message: "Try to re-authenticate because current refresh token is not valid."
error_message_contains: "401 Client Error: Unauthorized for url"
http_codes: [401]
- type: HttpResponseFilter
action: RETRY
http_codes: [500]

analytics_error_handler:
type: DefaultErrorHandler
backoff_strategies:
- type: ConstantBackoffStrategy
backoff_time_in_seconds: 1
response_filters:
- type: HttpResponseFilter
action: RETRY
http_codes: [400]

# Requester
requester:
type: HttpRequester
url_base: "https://api.pinterest.com/v5/"
http_method: GET
authenticator: "#/definitions/authenticator"
error_handler:
type: CompositeErrorHandler
error_handlers:
- type: DefaultErrorHandler
backoff_strategies:
- type: WaitTimeFromHeader
header: "X-RateLimit-Reset"
response_filters:
- type: HttpResponseFilter
action: IGNORE
error_message: "Max rate limit exceeded"
http_codes: [429]
predicate: "{{ response.get('code') == 8 }}"
- type: HttpResponseFilter
action: IGNORE
error_message: "Can't access catalog product groups because there is no existing catalog."
http_codes: [409]
- type: HttpResponseFilter
action: FAIL
error_message: "Try to re-authenticate because current refresh token is not valid."
error_message_contains: "401 Client Error: Unauthorized for url"
http_codes: [401]
- type: HttpResponseFilter
action: RETRY
http_codes: [500]
- type: DefaultErrorHandler
backoff_strategies:
- type: ConstantBackoffStrategy
backoff_time_in_seconds: 1
response_filters:
- type: HttpResponseFilter
action: RETRY
http_codes: [400]
predicate: "{{ response.get('code') > 0 }}"
error_handler: "#/definitions/base_error_handler"

# Selector
selector:
Expand Down Expand Up @@ -105,6 +106,11 @@ definitions:
type: NoPagination
requester:
$ref: "#/definitions/requester"
error_handler:
type: CompositeErrorHandler
error_handlers:
- "#/definitions/base_error_handler"
- "#/definitions/analytics_error_handler"
request_parameters:
granularity: "DAY"
columns: "ADVERTISER_ID,AD_ACCOUNT_ID,AD_GROUP_ENTITY_STATUS,AD_GROUP_ID,AD_ID,CAMPAIGN_DAILY_SPEND_CAP,CAMPAIGN_ENTITY_STATUS,CAMPAIGN_ID,CAMPAIGN_LIFETIME_SPEND_CAP,CAMPAIGN_NAME,CHECKOUT_ROAS,CLICKTHROUGH_1,CLICKTHROUGH_1_GROSS,CLICKTHROUGH_2,CPC_IN_MICRO_DOLLAR,CPM_IN_DOLLAR,CPM_IN_MICRO_DOLLAR,CTR,CTR_2,ECPCV_IN_DOLLAR,ECPCV_P95_IN_DOLLAR,ECPC_IN_DOLLAR,ECPC_IN_MICRO_DOLLAR,ECPE_IN_DOLLAR,ECPM_IN_MICRO_DOLLAR,ECPV_IN_DOLLAR,ECTR,EENGAGEMENT_RATE,ENGAGEMENT_1,ENGAGEMENT_2,ENGAGEMENT_RATE,IDEA_PIN_PRODUCT_TAG_VISIT_1,IDEA_PIN_PRODUCT_TAG_VISIT_2,IMPRESSION_1,IMPRESSION_1_GROSS,IMPRESSION_2,INAPP_CHECKOUT_COST_PER_ACTION,OUTBOUND_CLICK_1,OUTBOUND_CLICK_2,PAGE_VISIT_COST_PER_ACTION,PAGE_VISIT_ROAS,PAID_IMPRESSION,PIN_ID,PIN_PROMOTION_ID,REPIN_1,REPIN_2,REPIN_RATE,SPEND_IN_DOLLAR,SPEND_IN_MICRO_DOLLAR,TOTAL_CHECKOUT,TOTAL_CHECKOUT_VALUE_IN_MICRO_DOLLA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,TOTAL_WEB_ENGAGEMENT_CHECKOUT,TOTAL_WEB_ENGAGEMENT_CHECKOUT_VALUE_IN_MICRO_DOLLAR,TOTAL_WEB_SESSIONS,TOTAL_WEB_VIEW_CHECKOUT,TOTAL_WEB_VIEW_CHECKOUT_VALUE_IN_MICRO_DOLLAR,VIDEO_3SEC_VIEWS_2,VIDEO_LENGTH,VIDEO_MRC_VIEWS_2,VIDEO_P0_COMBINED_2,VIDEO_P100_COMPLETE_2,VIDEO_P25_COMBINED_2,VIDEO_P50_COMBINED_2,VIDEO_P75_COMBINED_2,VIDEO_P95_COMBINED_2,WEB_CHECKOUT_COST_PER_ACTION,WEB_CHECKOUT_ROAS,WEB_SESSIONS_1,WEB_SESSIONS_2"
Expand Down

0 comments on commit 333ee0f

Please sign in to comment.