Skip to content

[18.0][FIX] base_remote: allow RPC authentication without HTTP context#3612

Open
fsmw wants to merge 2 commits into
OCA:18.0from
fsmw:18.0-fix-base_remote-rpc-auth
Open

[18.0][FIX] base_remote: allow RPC authentication without HTTP context#3612
fsmw wants to merge 2 commits into
OCA:18.0from
fsmw:18.0-fix-base_remote-rpc-auth

Conversation

@fsmw
Copy link
Copy Markdown

@fsmw fsmw commented May 17, 2026

Fixes #3458

When authenticating via RPC (XML-RPC, JSON-RPC), there is no active
HTTP request context. The Base.remote property returns an empty
res.remote recordset in this case.

However, ResUsers._auth_check_remote unconditionally called
ensure_one() on that recordset, causing:

ValueError: Expected singleton: res.remote()

This blocked all API/RPC authentication while web login continued
to work normally.

Fix: Add and remote to the guard before ensure_one(),
skipping the singleton check when the remote recordset is empty.
This matches the existing pattern used for config['test_enable']
and does not affect web authentication where an HTTP context exists.

Tests:

  • Added test_auth_check_remote_no_http_context which patches
    Base.remote to return an empty recordset and verifies that
    _auth_check_remote tolerates it without crashing.
  • Existing tests for web login remain untouched.

Backward compatible: existing behaviour for browser sessions is
unchanged.

…ilure

Odoo 18 exp_authenticate() requires 4 arguments (db, login, password, user_agent_env).
The previous commit removed the empty dict, causing TypeError in CI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

base_remote: API authentication broken due to missing HTTP context check

2 participants