Skip to content

Clearer error message for a corrupt config or refresh token file (#268) - #974

Open
omaraldulimay wants to merge 2 commits into
Open-EO:masterfrom
omaraldulimay:refresh-token-store-corrupt-268
Open

omaraldulimay wants to merge 2 commits into
Open-EO:masterfrom
omaraldulimay:refresh-token-store-corrupt-268

Conversation

@omaraldulimay

@omaraldulimay omaraldulimay commented Nov 14, 2026 •

Copy link
Copy Markdown

Fixes #268

What changed

  • PrivateJsonFile.load() now raises a clearer RuntimeError when the file contains invalid JSON. It names the file, shows where the JSON is broken and suggests fixing or removing the file. The file itself is left untouched.
  • This covers both the auth config and the refresh token file. The exception type is unchanged.

Example:

RuntimeError: Failed to load RefreshTokenStore: '/home/user/.local/share/openeo-python-client/refresh-tokens.json' contains invalid JSON (Expecting property name enclosed in double quotes: line 1 column 2 (char 1)). Fix or remove this file and try again.

Tests

  • Updated test_load_corrupt_content in tests/rest/auth/test_config.py for the new message.
  • pytest tests/rest/auth tests/rest/test_connection.py: 509 passed.

This PR was drafted with the help of Claude Code.

@soxofaan soxofaan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is too aggressive: the original file will be fully wiped. While it might be corrupt, it might still be recoverable (e.g. user could want to manually fix it). The proposed change makes recovery impossible.
As originally proposed in #268 I would just improve the error message

…n-EO#268)

Instead of ignoring or overwriting a corrupt refresh token file, keep the
file untouched and raise a clearer error that names the file and suggests
fixing or removing it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: omaraldulimay <120497558+omaraldulimay@users.noreply.github.com>
@omaraldulimay omaraldulimay changed the title Ignore corrupt refresh token file instead of failing authentication (#268) Clearer error message for a corrupt config or refresh token file (#268) Nov 22, 2026
@omaraldulimay

Copy link
Copy Markdown
Author

Thanks @soxofaan, good point. I reverted the recovery logic: the file is no longer touched. The PR now only improves the error message, as proposed in #268. It names the file, shows where the JSON is broken and suggests fixing or removing it.

@soxofaan

Copy link
Copy Markdown
Member

@copilot resolve the merge conflicts in this pull request

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better handling of corrupt config/refresh token file

2 participants