question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

LocalFilesystemToS3Operator dest_key can not be a full s3:// style url

See original GitHub issue

Apache Airflow Provider(s)

amazon

Versions of Apache Airflow Providers

apache-airflow-providers-amazon==3.3.0 apache-airflow-providers-ftp==2.1.2 apache-airflow-providers-http==2.1.2 apache-airflow-providers-imap==2.2.3 apache-airflow-providers-mongo==2.3.3 apache-airflow-providers-sqlite==2.1.3

Apache Airflow version

2.3.0b1 (pre-release)

Operating System

Arch Linux

Deployment

Virtualenv installation

Deployment details

No response

What happened

LocalFilesystemToS3Operator does not accept full s3:// style url as dest_key, although it states, that it should:

    :param dest_key: The key of the object to copy to. (templated)

        It can be either full s3:// style url or relative path from root level.

        When it's specified as a full s3:// url, including dest_bucket results in a TypeError.

What you think should happen instead

LocalFilesystemToS3Operator should behave as documented.

How to reproduce

A modification of an existing UT:

    @mock_s3
    def test_execute_with_only_key(self):
        conn = boto3.client('s3')
        conn.create_bucket(Bucket=self.dest_bucket)
        operator = LocalFilesystemToS3Operator(
            task_id='s3_to_file_sensor',
            dag=self.dag,
            filename=self.testfile1,
            dest_key=f's3://dummy/{self.dest_key}',
            **self._config,
        )
        operator.execute(None)

        objects_in_dest_bucket = conn.list_objects(Bucket=self.dest_bucket, Prefix=self.dest_key)
        # there should be object found, and there should only be one object found
        assert len(objects_in_dest_bucket['Contents']) == 1
        # the object found should be consistent with dest_key specified earlier
        assert objects_in_dest_bucket['Contents'][0]['Key'] == self.dest_key

FAILED tests/providers/amazon/aws/transfers/test_local_to_s3.py::TestFileToS3Operator::test_execute_with_only_key - TypeError: expected string or bytes-like object

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
vincbeckcommented, Apr 20, 2022

After investigation, it seems it is not the only S3 related operator with this bug. Thanks for catching this! Unless you want or are currently working on this, I can take care of fixing these operators

1reaction
potiukcommented, Apr 20, 2022

Would you like to fix it @tanelk ? Sounds like an easy fix and you can become one of > 2000 contriibutors to airflow. Actually fixing it is the fastest way to proceed, otherwise it will have to wait for someone willing to pick it up.

Read more comments on GitHub >

github_iconTop Results From Across the Web

airflow.providers.amazon.aws.transfers.local_to_s3
It can be either full s3:// style url or relative path from root level. When it's specified as a full s3:// url, including...
Read more >
Virtual hosting of buckets - Amazon Simple Storage Service
Currently, Amazon S3 supports both virtual-hosted–style and path-style URL access in all AWS Regions. However, path-style URLs will be discontinued in the ...
Read more >
How to format a URL to get a file from Amazon S3?
There are 2 different URL styles: Virtual host style: https://BUCKET.s3.amazonaws.com/FILE; Path style: ... But this url does not work:.
Read more >
Amazon S3 Bucket Security: How to Find & Secure Open ...
Amazon S3 buckets are used for many enterprise use cases, ... Whether or not a bucket is accessible through its URL depends on...
Read more >
S3 Buckets: Accessing, Managing, and Securing Your Buckets
What Is S3 Bucket Policy? S3 Bucket URL and Other Methods to Access Your Buckets. Virtual-Hosted-Style Access; Path-Style Access; Accessing a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found