Skip to content
This repository has been archived by the owner on Feb 28, 2024. It is now read-only.

INDEX: using s3fs with expired token gives confusing error message #448

Open
volkfox opened this issue Jul 26, 2022 · 1 comment
Open

INDEX: using s3fs with expired token gives confusing error message #448

volkfox opened this issue Jul 26, 2022 · 1 comment

Comments

@volkfox
Copy link
Contributor

volkfox commented Jul 26, 2022

Need to decorate an error message a bit as the below is confusing.
The situation where LDB needs to access s3 but can't due to expired access token is common, so it should give ready instructions, along the lines of "please check S3 credentials"

Here the read-add location is on S3 for which the token is expired:

 ldb index --format bare /Users/dkh/Downloads/wine_cancellation.png
Data format: bare-pairs

Indexing paths...

Unable to finish indexing. Partial indexing results:
  Found data objects:            0
  Found annotations:             0
  New data objects:              0
  New annotations:               0
  New data object paths:         0

ERROR: OSError: [Errno 22] The provided token is malformed or otherwise invalid.
@jonburdo
Copy link
Contributor

jonburdo commented Jul 26, 2022

An s3 credentials error when indexing a local path would typically come from an s3 location configured as the read-add storage location.

Steps to reproduce a similar error:

  1. Create an aws config with a malformed token. For example, if valid credentials exist at ~/.aws/credentials for a profile configured with mfa, copy this file to a temporary location like ~/tmp/aws/credentials and add a few characters to the end of the aws_session_token value.
  2. Set env vars:
    AWS_PROFILE=your-profile
    AWS_SHARED_CREDENTIALS_FILE=~/tmp/aws/credentials
    
  3. Run ldb command that will try to access s3:
    ldb index s3://ldb-public/remote/data-lakes/dogs-and-cats -vv
    

s3fs catches botocore's base ClientError (i.e. any botocore error) and uses s3fs.errors.translate_boto_error to translate to a generic python error like OSError. This also typically sets the __cause__ attribute, so a general solution could be to catch exceptions, check for a __cause__ where isinstance on ClientError is true and add a message about it being an aws/s3 error. It could also make sense to link to: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/quickstart.html#configuration

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants