balanced / balanced-api

Balanced API specification.
220 stars 72 forks source link

hold.{save,cancel} is 404 immediately after .query? #727

Closed chadwhitacre closed 9 years ago

chadwhitacre commented 9 years ago
>>> holds = list(CardHold.query.filter(CardHold.f.meta.state == 'new'))
>>> len(holds)
566
>>> holds[0].save()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/app/.heroku/python/lib/python2.7/site-packages/balanced/resources.py", line 177, in save
    resp = method(href, data=attrs)
  File "/app/.heroku/python/lib/python2.7/site-packages/wac.py", line 460, in put
    return self._op(self.interface.put, uri, data=data, **kwargs)
  File "/app/.heroku/python/lib/python2.7/site-packages/wac.py", line 512, in _op
    handle_error(ex)
  File "/app/.heroku/python/lib/python2.7/site-packages/wac.py", line 489, in handle_error
    raise ex
balanced.exc.HTTPError: HTTPError(description='<p>The requested URL was not found on the server.</p><p>If you entered the URL manually please check your spelling and try again.</p> Your request id is OHM970805a491f311e485a702b12035401b.', request_id='OHM970805a491f311e485a702b12035401b', category_type='request', category_code='not-found', status_code=404, response=None, status='Not Found')
>>> holds[256].cancel()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/app/.heroku/python/lib/python2.7/site-packages/balanced/resources.py", line 289, in cancel
    return self.save()
  File "/app/.heroku/python/lib/python2.7/site-packages/balanced/resources.py", line 177, in save
    resp = method(href, data=attrs)
  File "/app/.heroku/python/lib/python2.7/site-packages/wac.py", line 460, in put
    return self._op(self.interface.put, uri, data=data, **kwargs)
  File "/app/.heroku/python/lib/python2.7/site-packages/wac.py", line 512, in _op
    handle_error(ex)
  File "/app/.heroku/python/lib/python2.7/site-packages/wac.py", line 489, in handle_error
    raise ex
balanced.exc.HTTPError: HTTPError(description='<p>The requested URL was not found on the server.</p><p>If you entered the URL manually please check your spelling and try again.</p> Your request id is OHMdac65dfe91f311e48c5306429171ffad.', request_id='OHMdac65dfe91f311e48c5306429171ffad', category_type='request', category_code='not-found', status_code=404, response=None, status='Not Found')
>>>

Surfaced on https://github.com/gratipay/gratipay.com/issues/3045.

mjallday commented 9 years ago

@whit537 what's the URI that it's attempting to PUT to?

Changaco commented 9 years ago

@mjallday Here's one: /card_holds/HL6RrhNZFtSKsncW4Cpt4T6D

mjallday commented 9 years ago

this hold failed to be created (card declined).

there's an internal job to reconcile these transactions that failed to run and as such this hold was not addressable by the api. i've fixed the job which appears to have been failing for the last few hours.

i can see a way to fix this so that this does not depend on the job. we'll have a fix available in a few days to resolve this.

mjallday commented 9 years ago

a fix has been deployed which should ensure that all failed holds are available via the api regardless of the background job. please let me know if this still appears to be an issue for you.

chadwhitacre commented 9 years ago

Awesome, thanks @mjallday! We ran into a similar situation this week and the Balanced part of the problem is indeed fixed now.