Skip to content

If policy file is empty, mc requests the user provides a Content-Length header #5108

@MrCreosote

Description

@MrCreosote

Expected behavior

When attempting to create a policy with the mc client, a empty policy document should cause the client to error out with a helpful error message.

Actual behavior

The mc client tells the user to provide a Content-Length header, which is not very helpful to the user, especially a newbie.

Steps to reproduce the behavior

~$ cat badpolicy.json 
~$ ~/minio/mc/RELEASE/2024-11-21T17-21-54Z/mc admin policy create local9000 badpolicy badpolicy.json
mc: <ERROR> Unable to create new policy. You must provide the Content-Length HTTP header.

mc --version

~$ ~/minio/mc/RELEASE/2024-11-21T17-21-54Z/mc admin info local9000
●  localhost:9000
   Uptime: 3 minutes 
   Version: 2024-12-18T13:15:44Z
*snip*
~$ ~/minio/mc/RELEASE/2024-11-21T17-21-54Z/mc -v
mc version RELEASE.2024-11-21T17-21-54Z (commit-id=1681e4497c09d7438a34e846f76dbde972ab7daf)
Runtime: go1.23.4 linux/amd64
Copyright (c) 2015-2024 MinIO, Inc.
License GNU AGPLv3 <https://www.gnu.org/licenses/agpl-3.0.html>

System information

Ubuntu 18 VM running on an Ubuntu 18 laptop. Upgrade plans are in motion

Other notes

I haven't tested with malformed JSON or valid JSON but mismatched with the policy schema - not sure what error messages those might return

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions