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

error while loading view: aws.AmazonQChatView (DiskCacheError) #6140

Closed
LewS opened this issue Dec 4, 2024 · 3 comments · Fixed by #6164
Closed

error while loading view: aws.AmazonQChatView (DiskCacheError) #6140

LewS opened this issue Dec 4, 2024 · 3 comments · Fixed by #6164
Labels
amazon-q bug We can reproduce the issue and confirmed it is a bug. filesystem

Comments

@LewS
Copy link

LewS commented Dec 4, 2024

Problem

AmazonQ worked for the first week or so, then when loaded shows the error
An error occurred while loading view: aws.AmazonQChatView
AmazonQ is set to auto update.
Udating vs code, does not fix the problem.

Steps to reproduce the issue

Install AmazonQ and wait for a week or so...
Amazon Q Logs.log

Expected behavior

Ability to use amazonq chat functionality

System details (run AWS: About and/or Amazon Q: About)

  • OS: Linux - Ubuntu 24.04
  • Visual Studio Code version: 1.95.3
  • AWS Toolkit version: v.1.39.0
  • Amazon Q version: v3.37.0
@LewS LewS added the bug We can reproduce the issue and confirmed it is a bug. label Dec 4, 2024
@justinmk3
Copy link
Contributor

2024-12-04 15:17:22.455 [warning] auth: failed to restore previous session: Error: Failed to update connection due to file system operation failures [DiskCacheError]
	 -> DiskCacheError: LOAD failed for '/home/lew/.aws/sso/cache/6e60c8cc5bae992900fecfad4781120f41eb6124.json' (key: dfd55e61-46f6-4faa-8b51-e13b49b26bc8)
	 -> SyntaxError: Unexpected end of JSON input
2024-12-04 15:17:22.465 [error] loadSavedConnection: Failed to refresh connection state: Error: Failed to update connection due to file system operation failures [DiskCacheError]
	 -> DiskCacheError: LOAD failed for '/home/lew/.aws/sso/cache/6e60c8cc5bae992900fecfad4781120f41eb6124.json' (key: dfd55e61-46f6-4faa-8b51-e13b49b26bc8)
	 -> SyntaxError: Unexpected end of JSON input
...
2024-12-04 15:17:22.493 [error] CodeWhisperer: Error when fetching feature configs Error: Failed to update connection due to file system operation failures

Looks like there are problems with the filesystem. We should handle this in a better way, but likely will still have problems if filesystem operations are failing.

@justinmk3 justinmk3 changed the title An error occurred while loading view: aws.AmazonQChatView error while loading view: aws.AmazonQChatView (DiskCacheError) Dec 4, 2024
@nkomonen-amazon
Copy link
Contributor

nkomonen-amazon commented Dec 4, 2024

It looks like the cache file is somehow becoming malformed. I've been seeing this in other places outside of auth (eg crash monitoring).

Agreed we should look to handle this more gracefully. I'll need to look in to it, but we may be able to force a token refresh to get a new cache. Otherwise we just invalidate, and at least the user can log in again.


@LewS would you be fine to paste the contents (with IDs/Tokens obfuscated) from: /home/lew/.aws/sso/cache/6e60c8cc5bae992900fecfad4781120f41eb6124.json. I just want to see what the malformed JSON looks like.

Then you should be able to log out then in again and it should be running again.

@LewS
Copy link
Author

LewS commented Dec 5, 2024

Hey Nikolas, 6e60c8cc5bae992900fecfad4781120f41eb6124.json is 0 bytes, so nothing to add :/
That gives you a perfect picture of it at least, and hopefully a clue as to where the deeper problem lays.
The toolkit json looks correct through.

karanA-aws pushed a commit to karanA-aws/aws-toolkit-vscode that referenced this issue Jan 17, 2025
## Problem:

When we loaded sso cache from disk, we would only invalidate (leading to
a reauth prompt) if the cache file was missing.

But if the cache file was present, though its content was malformed, we
would incorrectly treat it as recoverable by throwing instead of
returning undefined. Users would get stuck in a state where all future
api calls would fail, and they'd never get a prompt to reauth to fix
their SSO session.

## Solution:

If we detect a SyntaxError treat it as non-recoverable, meaning it will
trigger a reauth.

Also added some code to validate the content of the SSO cache we loaded
from disk to ensure it is what we expected.

Fixes aws#6140

---

- Treat all work as PUBLIC. Private `feature/x` branches will not be
squash-merged at release time.
- Your code changes must meet the guidelines in
[CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines).

License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.

---------

Signed-off-by: nkomonen-amazon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
amazon-q bug We can reproduce the issue and confirmed it is a bug. filesystem
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants