ansible-collections / ansible-collections/google.cloud

"'NoneType' object does not support item assignment" in gcp_storage_object

Open
#379 1 comment 0 reactions 0 assignees View on GitHub
stale
Dominant language
Python
Stars
105
Forks
144
Avg merge
5d 10h
Merged PRs (30d)
4

Description

##### SUMMARY

I get the following exception when I try to upload a file to Google storage:

```
The full traceback is:
Traceback (most recent call last):
File "/Users/maroun.bassam/.ansible/tmp/ansible-tmp-1613983611.6898382-65652-79762399834691/AnsiballZ_gcp_storage_object.py", line 247, in
_ansiballz_main()
File "/Users/maroun.bassam/.ansible/tmp/ansible-tmp-1613983611.6898382-65652-79762399834691/AnsiballZ_gcp_storage_object.py", line 237, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/Users/maroun.bassam/.ansible/tmp/ansible-tmp-1613983611.6898382-65652-79762399834691/AnsiballZ_gcp_storage_object.py", line 108, in invoke_module
runpy.run_module(mod_name='ansible.modules.cloud.google.gcp_storage_object', init_globals=None, run_name='__main__', alter_sys=True)
File "/usr/local/Cellar/python@3.8/3.8.6_2/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 207, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/usr/local/Cellar/python@3.8/3.8.6_2/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/usr/local/Cellar/python@3.8/3.8.6_2/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/var/folders/wh/zy6_yz8n67d0w2_40cmcylfw0000gn/T/ansible_gcp_storage_object_payload_j9qs76d7/ansible_gcp_storage_object_payload.zip/ansible/modules/cloud/google/gcp_storage_object.py", line 286, in
File "/var/folders/wh/zy6_yz8n67d0w2_40cmcylfw0000gn/T/ansible_gcp_storage_object_payload_j9qs76d7/ansible_gcp_storage_object_payload.zip/ansible/modules/cloud/google/gcp_storage_object.py", line 168, in main
TypeError: 'NoneType' object does not support item assignment
```

##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME

`gcp_storage_object`

##### ANSIBLE VERSION

```paste below
2.9.12
```

##### CONFIGURATION

```paste below
DEFAULT_CALLBACK_WHITELIST(/Users/maroun.bassam/protean/devops/ansible/ansible.cfg) = ['profile_tasks']
DEFAULT_HOST_LIST(/Users/maroun.bassam/protean/devops/ansible/ansible.cfg) = ['/Users/maroun.bassam/protean/devops/ansible/inventory.yml']
DEFAULT_KEEP_REMOTE_FILES(env: ANSIBLE_KEEP_REMOTE_FILES) = True
HOST_KEY_CHECKING(/Users/maroun.bassam/protean/devops/ansible/ansible.cfg) = False
```

##### OS / ENVIRONMENT

MacOS

##### STEPS TO REPRODUCE

Just try to upload a file:

```
- name: create file
gcp_storage_object:
action: upload
project: project_id
bucket: my_bucket
src: "/Users/test.txt"
dest: "test.txt"
state: present
```

##### EXPECTED RESULTS

I expect the file to be uploaded.

##### ACTUAL RESULTS

The exception pasted above.

Contributor guide

Open the contributing guide

Research direction

Start in ansible.modules.cloud.google.gcp_storage_object, especially main() around line 168 shown in the traceback, and reproduce the upload with the provided playbook task. Confirm the module handles this upload without the NoneType exception and that the file is uploaded as expected.

Written by the indexing model from the issue text.

Assessment

Tech stack
gcp, python
Domain
cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.