Skip to content

Invalid import in cache_lock.py – portalocker.exceptions does not exist #145

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

Open
daga05 opened this issue May 29, 2025 · 3 comments
Open
Labels
question Further information is requested

Comments

@daga05
Copy link

daga05 commented May 29, 2025

We're encountering a runtime failure using msal-extensions==1.3.1 due to an invalid reference to portalocker.exceptions in cache_lock.py:

LockError = portalocker.exceptions.LockException

This causes authentication logic to break with:

AttributeError: module 'portalocker' has no attribute 'exceptions'

The current version of the portalocker package (e.g., 2.10.1) no longer exposes an exceptions module or attribute at the top level.

Suggested Fix:

Change the reference to:

import portalocker
LockError = portalocker.LockException

Confirmed Environment:

msal-extensions: 1.3.1
portalocker: 2.10.1
Python 3.11
Runtime: Azure App Service (Linux)

Please let us know if a fix can be included in the next release. We're happy to help validate or contribute a PR.

@junior-juarez-MSFT
Copy link

Here is the full exception

CertificateCredential.get_token failed: Authentication failed: module 'portalocker' has no attribute 'exceptions'

@rayluo rayluo added the question Further information is requested label May 29, 2025
@rayluo
Copy link
Contributor

rayluo commented May 29, 2025

But I am not able to reproduce the issue.

pip list
Package        Version
-------------- -------
pip            25.0.1
portalocker    2.10.1
security_state 0.0.0
setuptools     78.1.0
wheel          0.45.1
py3: commands[1]> python -c 'import portalocker; portalocker.exceptions.LockException; print("import successfully")'
import successfully

Can you share a way to reproduce it?

@rayluo
Copy link
Contributor

rayluo commented May 29, 2025

Further suggestions.

The issue WOULD happen if BOTH of the following conditions were met:

  1. Customer's code explicitly uses the cache_lock.py
  2. Customer's environment does NOT have portalocker installed.

HOWEVER, neither of the two conditions should occur.

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

No branches or pull requests

3 participants