fossology-python icon indicating copy to clipboard operation
fossology-python copied to clipboard

foss_cli: Not able to upload a file (error:fossology.exceptions.FossologyApiError: Upload upload via foss-cli could not be performed: Require uploadType (400))

Open IrinSamuel opened this issue 1 year ago • 3 comments

Hi,

I installed fossology 3.2.0 and used the foss_cli. The fossology server is spinned up using docker and available and running at http://localhost:8081/repo These are the commands followed:

  1. foss_cli config
  2. foss_cli -vv create_group FossGroup
  3. foss_cli -vv create_folder FossFolder --folder_group FossGroup --folder_description "Description of FossFolder"
  4. foss_cli -vv upload_file --folder_name FossFolder --access_level public /mnt/c/Users/xxx/Downloads/xxx.tar.gz

Step1 to 3 works, but for Step4, this is the output I get,


2024-04-30 11:20:23,035 - DEBUG - [foss_cli.py:305] - foss_cli called with: ['/home/xxxx/env_fossology/bin/foss_cli', '-vv', 'upload_file', '--folder_name', 'FossFolder', '--access_level', 'public', '/mnt/c/Users/xxxx/Downloads/xxxx.tar.gz'] 2024-04-30 11:20:23,035 - DEBUG - [foss_cli.py:146] - Function needs_later_initialization_of_foss_instance called {'DEBUG': False, 'IS_REQUEST_FOR_CONFIG': False, 'IS_REQUEST_FOR_HELP': False, 'RESULT_DIR': '.foss_cli_results', 'TOKEN': None, 'VERBOSE': 2} 2024-04-30 11:20:23,035 - DEBUG - [foss_cli.py:309] - Initializing Fossology client according to the CLI context 2024-04-30 11:20:23,035 - DEBUG - [foss_cli.py:198] - INIT FOSS 2024-04-30 11:20:23,035 - DEBUG - [foss_cli.py:207] - Set server token from configfile http://localhost:8081/repo:xxxx 2024-04-30 11:20:23,179 - DEBUG - [foss_cli.py:224] - Logged in as user fossy 2024-04-30 11:20:23,184 - DEBUG - [foss_cli.py:555] - Try to upload file /mnt/c/Users/xxxx/Downloads/xxxx.tar.gz 2024-04-30 11:20:23,184 - DEBUG - [foss_cli.py:94] - Found upload folder FossFolder with id 3 Traceback (most recent call last): File "/home/xxxx/env_fossology/bin/foss_cli", line 8, in sys.exit(main()) ^^^^^^ File "/home/xxxx/env_fossology/lib/python3.12/site-packages/fossology/foss_cli.py", line 813, in main cli(obj=d) # pragma: no cover ^^^^^^^^^^ File "/home/xxxx/env_fossology/lib/python3.12/site-packages/click/core.py", line 1157, in call return self.main(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/xxxx/env_fossology/lib/python3.12/site-packages/click/core.py", line 1078, in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ File "/home/xxxx/env_fossology/lib/python3.12/site-packages/click/core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/xxxx/env_fossology/lib/python3.12/site-packages/click/core.py", line 1434, in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/xxxx/env_fossology/lib/python3.12/site-packages/click/core.py", line 783, in invoke return __callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/xxxx/env_fossology/lib/python3.12/site-packages/click/decorators.py", line 33, in new_func return f(get_current_context(), *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/xxxx/env_fossology/lib/python3.12/site-packages/fossology/foss_cli.py", line 570, in upload_file the_upload = foss.upload_file( ^^^^^^^^^^^^^^^^^ File "/home/xxxx/env_fossology/lib/python3.12/site-packages/fossology/uploads.py", line 309, in upload_file raise FossologyApiError(description, response) fossology.exceptions.FossologyApiError: Upload upload via foss-cli could not be performed: Require uploadType (400)


I also tried different other type of files (*.zip, *.txt) to upload, but could not do it successfully. However, uploading manually is successfull. Can you let me know what is wrong.

Thanks and regards, Irin

IrinSamuel avatar Apr 30 '24 09:04 IrinSamuel

Dear @IrinSamuel,

thanks for the very precise bug report. This error has been fixed in version 3.2.1: https://github.com/fossology/fossology-python/releases/tag/v3.2.1.

Can you give it a try?

deveaud-m avatar May 05 '24 20:05 deveaud-m

Hi @deveaud-m

Thanks for your answer. I tried now with the latest v3.2.1 and it works. However, this release is not available with pip install https://pypi.org/project/fossology/

The latest there is still 3.2.0. Can you please add this release there as well so that I can use it with pip and not do a manual install?

Thanks and regards, Irin

IrinSamuel avatar May 13 '24 15:05 IrinSamuel

@deveaud-m any updates on this one? Can you publish 3.2.1 to pypi.org

IrinSamuel avatar May 21 '24 07:05 IrinSamuel

@IrinSamuel sorry for the long delay, I missed your comment, I just published the package on PyPi: https://pypi.org/project/fossology/3.2.1/

deveaud-m avatar Jun 15 '24 06:06 deveaud-m