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

RuntimeError when accessing the current request on XML-RPC calls #24183

Closed
yajo opened this issue Apr 11, 2018 · 4 comments
Closed

RuntimeError when accessing the current request on XML-RPC calls #24183

yajo opened this issue Apr 11, 2018 · 4 comments
Labels
9.0 10.0 11.0 Framework General frontend/backend framework issues Wishlist

Comments

@yajo
Copy link
Contributor

yajo commented Apr 11, 2018

Impacted versions: 8-11

Current behavior:

If during an XMLRPC call you try to get anything from http.request, you'd get a RuntimeError such as this one:

Traceback (most recent call last):
  File "/opt/odoo/custom/src/odoo/odoo/service/wsgi_server.py", line 56, in xmlrpc_return
    result = odoo.http.dispatch_rpc(service, method, params)
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 118, in dispatch_rpc
    result = dispatch(method, params)
  File "/opt/odoo/custom/src/odoo/odoo/service/common.py", line 57, in dispatch
    return g[exp_method_name](*params)
  [...]
  File "/usr/local/lib/python2.7/dist-packages/werkzeug/local.py", line 343, in __getattr__
    return getattr(self._get_current_object(), name)
  File "/usr/local/lib/python2.7/dist-packages/werkzeug/local.py", line 302, in _get_current_object
    return self.__local()
  File "/usr/local/lib/python2.7/dist-packages/werkzeug/local.py", line 135, in _lookup
    raise RuntimeError(\'object unbound\')
RuntimeError: object unbound

This renders imposible in practice to fix issues such as OCA/server-tools#1125 or to implement #22212 (comment).

Expected behavior:

XML-RPC calls should have request, since after all they belong to one. Otherwise, at least there should be an alternate way to access the request parameters.

Fix for v12: #24187

@Tecnativa

@yajo yajo changed the title Not possible to access the current request on XML-RPC calls RuntimeError when accessing the current request on XML-RPC calls Apr 11, 2018
@Yenthe666 Yenthe666 added Framework General frontend/backend framework issues 11.0 10.0 9.0 labels Apr 11, 2018
yajo added a commit to Tecnativa/server-tools that referenced this issue Apr 12, 2018
To fix OCA#1125 I needed to refactor the addon.

The fix is affected by odoo/odoo#24183 and will not work until it gets fixed upstream due to the technical limitations implied. This PR is implemented assuming odoo/odoo#24187 will be merged and backported.
@nhomar
Copy link
Collaborator

nhomar commented Apr 12, 2018

@yajo Can you share a snippet of the script you are using, please? I can not reproduce on my side.

@nhomar nhomar added the Need information the reports lacks of information label Apr 12, 2018
@yajo
Copy link
Contributor Author

yajo commented Apr 16, 2018

Yes, you need to try to get the request details from a method that can be called from a XMLRPC call. I.e.:

from odoo import api, http, models
class ResUsers(models.Model):
  @api.model
  def check_credentials(self):
    # Log the remote login IP
    print(http.request.httprequest.remote_addr)
    return super(ResUsers, self).check_credentials()

Then you have to connect to that database through XMLRPC and execute that method. In the example, that happens just by authenticating, like explained in the docs.

A quick search revealed related issues such as #21530 or #14939.

@odony
Copy link
Contributor

odony commented Apr 16, 2018

This is the expected behavior as of today, as the XML-RPC layer is implemented separately from the regular web layer. This is from historical reasons, and originally allowed the XML-RPC stack to operate without the web client.
You could either rephrase this issue as a Wishlist request for converting the XMLRPC layer to a normal controller, or close it as "not a bug".

Issues like #21530 or #14939 seem to indicate that odoo.http.request was used without precautions in addons code where it is not guaranteed to exist (e.g. when called via XMLRPC, or when invoked by an ir.cron job, etc.)

@odony odony added Wishlist and removed Need information the reports lacks of information labels Apr 16, 2018
yajo added a commit to Tecnativa/server-tools that referenced this issue Apr 27, 2018
To fix OCA#1125 I needed to refactor the addon. To whitelist IPs now you use a config parameter, which renders res.banned.remote model unneeded.

The fix is affected by odoo/odoo#24183 and will not work until it gets fixed upstream due to the technical limitations implied.
xmo-odoo pushed a commit to Tecnativa/odoo that referenced this issue May 8, 2018
This way, XMLRPC calls can get request details form the standard
`odoo.http.request` system.

Move jsonrpc to the same controller while at it, for coherence.

Fix odoo#24183
xmo-odoo pushed a commit that referenced this issue May 9, 2018
This way, XMLRPC calls can get request details form the standard
`odoo.http.request` system.

Move jsonrpc to the same controller while at it, for coherence.

Fix #24183
@MiquelRForgeFlow
Copy link
Contributor

This can be closed, right?

@xmo-odoo xmo-odoo closed this as completed May 9, 2018
yajo added a commit to OCA/server-tools that referenced this issue May 18, 2018
To fix #1125 I needed to refactor the addon. To whitelist IPs now you use a config parameter, which renders res.banned.remote model unneeded.

The fix is affected by odoo/odoo#24183 and will not work until it gets fixed upstream due to the technical limitations implied.
yajo added a commit to Tecnativa/server-auth that referenced this issue May 21, 2018
To fix OCA/server-tools#1125 I needed to refactor the addon. To whitelist IPs now you use a config parameter, which renders res.banned.remote model unneeded.

The fix is affected by odoo/odoo#24183 and will not work until it gets fixed upstream due to the technical limitations implied.

[FIX] auth_brute_force: Small typos

- The `whitelisted` field needs to exist in view to be usable.
- The correct class is `decoration-danger` for tree views.
yajo added a commit to Tecnativa/server-auth that referenced this issue May 21, 2018
To fix OCA/server-tools#1125 I needed to refactor the addon. To whitelist IPs now you use a config parameter, which renders res.banned.remote model unneeded.

The fix is affected by odoo/odoo#24183 and will not work until it gets fixed upstream due to the technical limitations implied.

[FIX] auth_brute_force: Small typos (#1250)

- The `whitelisted` field needs to exist in view to be usable.
- The correct class is `decoration-danger` for tree views.
yajo added a commit to Tecnativa/server-auth that referenced this issue May 21, 2018
…1219)

To fix OCA/server-tools#1125 I needed to refactor the addon. To whitelist IPs now you use a config parameter, which renders res.banned.remote model unneeded.

The fix is affected by odoo/odoo#24183 and will not work until it gets fixed upstream due to the technical limitations implied.

[FIX] auth_brute_force: Small typos (OCA/server-tools#1250)

- The `whitelisted` field needs to exist in view to be usable.
- The correct class is `decoration-danger` for tree views.
yajo added a commit to Tecnativa/server-auth that referenced this issue May 21, 2018
…1219)

To fix OCA/server-tools#1125 I needed to refactor the addon. To whitelist IPs now you use a config parameter, which renders res.banned.remote model unneeded.

The fix is affected by odoo/odoo#24183 and will not work until it gets fixed upstream due to the technical limitations implied.

[FIX] auth_brute_force: Small typos (OCA/server-tools#1250)

- The `whitelisted` field needs to exist in view to be usable.
- The correct class is `decoration-danger` for tree views.

[FIX] auth_brute_force: Fix addon requirement computation (OCA/server-tools#1251)

Include HACK for odoo/odoo#24833, which explains the false positive problem we were having here: an addon being importable doesn't mean it is installed.
yajo added a commit to Tecnativa/server-auth that referenced this issue May 22, 2018
To fix OCA/server-tools#1125 I needed to refactor the addon. To whitelist IPs now you use a config parameter, which renders res.banned.remote model unneeded.

The fix is affected by odoo/odoo#24183 and will not work until it gets fixed upstream due to the technical limitations implied.
yajo added a commit to Tecnativa/server-auth that referenced this issue May 22, 2018
…1219)

To fix OCA/server-tools#1125 I needed to refactor the addon. To whitelist IPs now you use a config parameter, which renders res.banned.remote model unneeded.

The fix is affected by odoo/odoo#24183 and will not work until it gets fixed upstream due to the technical limitations implied.
yajo added a commit to Tecnativa/server-tools that referenced this issue May 24, 2018
To fix OCA#1125 I needed to refactor the addon. To whitelist IPs now you use a config parameter, which renders res.banned.remote model unneeded.

The fix is affected by odoo/odoo#24183 and will not work until it gets fixed upstream due to the technical limitations implied.
daramousk pushed a commit to daramousk/server-tools that referenced this issue Jul 16, 2018
To fix OCA#1125 I needed to refactor the addon. To whitelist IPs now you use a config parameter, which renders res.banned.remote model unneeded.

The fix is affected by odoo/odoo#24183 and will not work until it gets fixed upstream due to the technical limitations implied.
daramousk pushed a commit to daramousk/server-tools that referenced this issue Oct 2, 2019
To fix OCA#1125 I needed to refactor the addon. To whitelist IPs now you use a config parameter, which renders res.banned.remote model unneeded.

The fix is affected by odoo/odoo#24183 and will not work until it gets fixed upstream due to the technical limitations implied.
kait-avalah pushed a commit to kait-avalah/server-tools that referenced this issue Jul 21, 2020
To fix OCA#1125 I needed to refactor the addon. To whitelist IPs now you use a config parameter, which renders res.banned.remote model unneeded.

The fix is affected by odoo/odoo#24183 and will not work until it gets fixed upstream due to the technical limitations implied.
kait-avalah pushed a commit to kait-avalah/server-tools that referenced this issue Jul 21, 2020
To fix OCA#1125 I needed to refactor the addon. To whitelist IPs now you use a config parameter, which renders res.banned.remote model unneeded.

The fix is affected by odoo/odoo#24183 and will not work until it gets fixed upstream due to the technical limitations implied.
kait-avalah pushed a commit to kait-avalah/server-tools that referenced this issue Aug 25, 2020
To fix OCA#1125 I needed to refactor the addon. To whitelist IPs now you use a config parameter, which renders res.banned.remote model unneeded.

The fix is affected by odoo/odoo#24183 and will not work until it gets fixed upstream due to the technical limitations implied.
nikunjantala pushed a commit to Nitrokey/odoo-server-auth that referenced this issue Sep 5, 2022
…1219)

To fix OCA/server-tools#1125 I needed to refactor the addon. To whitelist IPs now you use a config parameter, which renders res.banned.remote model unneeded.

The fix is affected by odoo/odoo#24183 and will not work until it gets fixed upstream due to the technical limitations implied.
nikunjantala pushed a commit to Nitrokey/odoo-server-auth that referenced this issue Sep 28, 2022
…1219)

To fix OCA/server-tools#1125 I needed to refactor the addon. To whitelist IPs now you use a config parameter, which renders res.banned.remote model unneeded.

The fix is affected by odoo/odoo#24183 and will not work until it gets fixed upstream due to the technical limitations implied.
nikunjantala pushed a commit to Nitrokey/odoo-server-auth that referenced this issue Oct 10, 2022
…1219)

To fix OCA/server-tools#1125 I needed to refactor the addon. To whitelist IPs now you use a config parameter, which renders res.banned.remote model unneeded.

The fix is affected by odoo/odoo#24183 and will not work until it gets fixed upstream due to the technical limitations implied.
dsolanki-initos pushed a commit to Nitrokey/odoo-server-auth that referenced this issue Nov 30, 2022
…1219)

To fix OCA/server-tools#1125 I needed to refactor the addon. To whitelist IPs now you use a config parameter, which renders res.banned.remote model unneeded.

The fix is affected by odoo/odoo#24183 and will not work until it gets fixed upstream due to the technical limitations implied.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
9.0 10.0 11.0 Framework General frontend/backend framework issues Wishlist
Projects
None yet
Development

No branches or pull requests

6 participants