Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide named error for calling SkygearContainer that is init before the transport ready #158

Open
2 tasks
rickmak opened this issue Aug 31, 2017 · 0 comments
Labels

Comments

@rickmak
Copy link
Member

rickmak commented Aug 31, 2017

Developer will write code like this.

container = SkygearContainer()

@skygear.op('booking:new', user_required=True)
def new_booking(info):
    container.send_action('record:save', {})

Since v0.24.0, default SkygearContainer.send_action is injected after py-skygear init and load the config from envvar. If the user created an instance before the config finished, the transport can be None and calling of send_cation will result in following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/skygear/transmitter/common.py", line 40, in wrapper
    return dict(result=f(self, *args, **kwargs))
  File "/usr/local/lib/python3.4/site-packages/skygear/transmitter/common.py", line 102, in call_func
    return self.hook(obj, param)
  File "/usr/local/lib/python3.4/site-packages/skygear/transmitter/common.py", line 180, in hook
    returned = func(record, original_record, conn)
  File "/usr/local/lib/python3.4/site-packages/skygear/decorators.py", line 85, in hook_func
    func(record, original_record, db)
  File "./skygear_plugins/tailor_image_resizing.py", line 104, in after_save_product_image
    DB_TABLES.get('product')
  File "./skygear_plugins/tailor_image_resizing.py", line 136, in resize_image_and_save_to_skygear_db
    image_url = get_image_url(record, field, table)
  File "./skygear_plugins/tailor_image_resizing.py", line 197, in get_image_url
    response = container.send_action('record:query', data)
  File "/usr/local/lib/python3.4/site-packages/skygear/container.py", line 106, in send_action
    resp = self.transport.send_action(action_name, payload, url, timeout)
AttributeError: 'NoneType' object has no attribute 'send_action'
  • Skygear Server Date/Version: v1.1.0
  • Application Platform:
  • Is this a regression?
  • Attached logs, screenshots

Expected Results

Tell the dev the transport is not ready at the instantiation time.

Actual Results

Meaningless error message of AttributeError.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant