dj-stripe: Account logo sync failing on test mode due to logo with error "a similar object exists in live mode, but a test mode key was used to make this request."

Account sync fails vs test mode because we get the same Account data back from Stripe for test/live, but the logo file isn’t readable with the test API keys.

Hits this error:

stripe.error.InvalidRequestError: Request req_uxFvzbEMllX3Mx: No such file upload: file_1E4RQtBC5mELIEO8f7E0fKr3; a similar object exists in live mode, but a test mode key was used to make this request.

Related to #823 , reported by @williamflynt in https://github.com/dj-stripe/dj-stripe/issues/823#issuecomment-464424384

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 25 (9 by maintainers)

Commits related to this issue

Most upvoted comments

As a temporary workaround, hook method can be monkey patched to ignore icon and logo fields in test mode.

_original_account_manipulate_stripe_object_hook = Account._manipulate_stripe_object_hook
def _account_manipulate_stripe_object_hook(cls, data):
    if not settings.STRIPE_LIVE_MODE:
        data["settings"]["branding"]["icon"] = None
        data["settings"]["branding"]["logo"] = None
    return _original_account_manipulate_stripe_object_hook(data)
Account._manipulate_stripe_object_hook = classmethod(
    _account_manipulate_stripe_object_hook
)

@therefromhere: save some sanity, here’s what’s breaking with the master build re: instantiating an account when syncing up with Stripe.

Within Stripe dashboard -> Business Settings -> Branding, ‘icon’ is the file/image the code’s looking for, not ‘logo’.

For those who set an icon image, no problems will be had. For those who don’t or only set a logo image, well then how dare you, hurk die.

tl;dr: FAKE_ACCOUNT.business_logo doesn’t reference Stripe.Business Settings.Branding.Logo, it goes looking for Stripe.Business Settings.Branding.Icon and falls apart when Amazon doesn’t deliver the goods, so test case passes because FAKE_ACCOUNT pushes it in then checks for the image, but if you’re pulling it from Stripe, then some code massaging and try/catching in that block of code just needs to be updated.

I’ll tackle it later if your hands are full, only have time to push the observations in here so only one of us has to lose sanity figuring this nuanced issue out.

I have a workaround for this in dj-stripe. Will PR it soon.

Hi

I had the opposite error message: Request req_D1eZsAUFS9KdfN: No such file upload: ‘file_1H8w95DynT2vGDTfYQb69lfD’; a similar object exists in test mode, but a live mode key was used to make this request.

Seems like if you upload the image while in test/live you’ll be able to use it only with the matching keys. I re-uploaded the image while in live mode, and resent the webhook, and then it worked.

Master.