You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "zachliu (via GitHub)" <gi...@apache.org> on 2025/10/23 16:15:18 UTC

[PR] Add the missing bucket_name argument [airflow]

zachliu opened a new pull request, #57159:
URL: https://github.com/apache/airflow/pull/57159

   When the argument `bucket_name` is passed through `get_file_metadata`, the `iter_file_metadata` doesn't actually use it. This creates an issue in the code. You'd get a rather subtle error that may be hard to troubleshoot:
   
   ```
   TypeError: expected string or bytes-like object, got 'NoneType'
   File "/usr/local/airflow/.local/lib/python3.12/site-packages/airflow/sdk/execution_time/task_runner.py", line 920 in run
   File "/usr/local/airflow/.local/lib/python3.12/site-packages/airflow/sdk/execution_time/task_runner.py", line 1307 in _execute_task
   File "/usr/local/airflow/.local/lib/python3.12/site-packages/airflow/sdk/bases/operator.py", line 416 in wrapper
   File "/usr/local/airflow/.local/lib/python3.12/site-packages/airflow/providers/amazon/aws/sensors/s3.py", line 198 in execute
   File "/usr/local/airflow/.local/lib/python3.12/site-packages/airflow/sdk/bases/operator.py", line 416 in wrapper
   File "/usr/local/airflow/.local/lib/python3.12/site-packages/airflow/sdk/bases/sensor.py", line 227 in execute
   File "/usr/local/airflow/.local/lib/python3.12/site-packages/airflow/sdk/bases/sensor.py", line 207 in execute
   File "/usr/local/airflow/.local/lib/python3.12/site-packages/airflow/providers/amazon/aws/hooks/s3.py", line 127 in wrapper
   File "/usr/local/airflow/.local/lib/python3.12/site-packages/airflow/providers/amazon/aws/hooks/s3.py", line 948 in get_file_metadata
   File "/usr/local/airflow/.local/lib/python3.12/site-packages/airflow/providers/amazon/aws/hooks/s3.py", line 985 in iter_file_metadata
   File "/usr/local/airflow/.local/lib/python3.12/site-packages/botocore/paginate.py", line 272 in __iter__
   File "/usr/local/airflow/.local/lib/python3.12/site-packages/botocore/context.py", line 123 in wrapper
   File "/usr/local/airflow/.local/lib/python3.12/site-packages/botocore/paginate.py", line 360 in _make_request
   File "/usr/local/airflow/.local/lib/python3.12/site-packages/botocore/client.py", line 602 in _api_call
   File "/usr/local/airflow/.local/lib/python3.12/site-packages/botocore/context.py", line 123 in wrapper
   File "/usr/local/airflow/.local/lib/python3.12/site-packages/botocore/client.py", line 1019 in _make_api_call
   File "/usr/local/airflow/.local/lib/python3.12/site-packages/botocore/client.py", line 1138 in _emit_api_params
   File "/usr/local/airflow/.local/lib/python3.12/site-packages/botocore/hooks.py", line 412 in emit
   File "/usr/local/airflow/.local/lib/python3.12/site-packages/botocore/hooks.py", line 256 in emit
   File "/usr/local/airflow/.local/lib/python3.12/site-packages/botocore/hooks.py", line 239 in _emit
   File "/usr/local/airflow/.local/lib/python3.12/site-packages/botocore/handlers.py", line 316 in validate_bucket_name
   ```
   
   <!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at
   
      http://www.apache.org/licenses/LICENSE-2.0
   
    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
    -->
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of an existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   
   
   <!-- Please keep an empty line above the dashes. -->
   ---
   **^ Add meaningful description above**
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
   In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add missing bucket_name to `get_file_metadata` in `S3Hook` [airflow]

Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck merged PR #57159:
URL: https://github.com/apache/airflow/pull/57159


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add missing bucket_name to `get_file_metadata` in `S3Hook` [airflow]

Posted by "zachliu (via GitHub)" <gi...@apache.org>.
zachliu commented on PR #57159:
URL: https://github.com/apache/airflow/pull/57159#issuecomment-3444536067

   > Would be cool to update/add test to cover that
   
   @vincbeck i did think about it. but ppl are supposed to deprecate `get_file_metadata` and use `iter_file_metadata`. and its tests were just removed in https://github.com/apache/airflow/commit/6a10bc6bf9446ae1ceeaeda95e9b8ee0d867bf99
   
   <img width="658" height="230" alt="2025-10-24_15-06" src="https://github.com/user-attachments/assets/3a0c410f-4dd2-4b5e-aed1-6504cd1d9c0b" />
   
   i can add it back like this if you insist :wink: 
   ```python
   def test_get_file_metadata(self, s3_bucket):
       hook = S3Hook()
       bucket = hook.get_bucket(s3_bucket)
       bucket.put_object(Key="test", Body=b"a")
   
       assert len(hook.get_file_metadata("t", s3_bucket)) == len(hook.iter_file_metadata("t", s3_bucket))
       assert hook.get_file_metadata("t", s3_bucket)[0]["Size"] == hook.iter_file_metadata("t", s3_bucket)[0]["Size"]
       assert len(hook.get_file_metadata("test", s3_bucket)) == len(hook.iter_file_metadata("test", s3_bucket))
       assert len(hook.get_file_metadata("a", s3_bucket)) == len(hook.iter_file_metadata("a", s3_bucket))
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add missing bucket_name to `get_file_metadata` in `S3Hook` [airflow]

Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on PR #57159:
URL: https://github.com/apache/airflow/pull/57159#issuecomment-3444662280

   > > Would be cool to update/add test to cover that
   > 
   > @vincbeck i did think about it. but ppl are supposed to deprecate `get_file_metadata` and use `iter_file_metadata`. and its tests were just removed in [6a10bc6](https://github.com/apache/airflow/commit/6a10bc6bf9446ae1ceeaeda95e9b8ee0d867bf99)
   > 
   > <img alt="2025-10-24_15-06" width="658" height="230" src="https://private-user-images.githubusercontent.com/14293802/505465486-3a0c410f-4dd2-4b5e-aed1-6504cd1d9c0b.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NjEzMzUxMjUsIm5iZiI6MTc2MTMzNDgyNSwicGF0aCI6Ii8xNDI5MzgwMi81MDU0NjU0ODYtM2EwYzQxMGYtNGRkMi00YjVlLWFlZDEtNjUwNGNkMWQ5YzBiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTEwMjQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUxMDI0VDE5NDAyNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTNjZGUxNDM2OWM3MzU5NzRiYjNlZWUzYTBkZGU2YzdjYjAzMjQ4YmJkNWExMTQxMjY2ODU3YjBlZWQ3NDQ4Y2QmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.HBnx06yKpjqRTffJFPA87_4bzOpoY_Y3Jdu-bEtyDT0">
   > i can add it back like this if you insist 😉
   > 
   > ```python
   > def test_get_file_metadata(self, s3_bucket):
   >     hook = S3Hook()
   >     bucket = hook.get_bucket(s3_bucket)
   >     bucket.put_object(Key="test", Body=b"a")
   > 
   >     assert len(hook.get_file_metadata("t", s3_bucket)) == len(hook.iter_file_metadata("t", s3_bucket))
   >     assert hook.get_file_metadata("t", s3_bucket)[0]["Size"] == hook.iter_file_metadata("t", s3_bucket)[0]["Size"]
   >     assert len(hook.get_file_metadata("test", s3_bucket)) == len(hook.iter_file_metadata("test", s3_bucket))
   >     assert len(hook.get_file_metadata("a", s3_bucket)) == len(hook.iter_file_metadata("a", s3_bucket))
   > ```
   
   Oh! No then it is fine I think 👌 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org