Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regression: Using --set with null value no longer translates to empty object #3846

Closed
anderseknert opened this issue Oct 1, 2021 · 0 comments · Fixed by #3862
Closed

regression: Using --set with null value no longer translates to empty object #3846

anderseknert opened this issue Oct 1, 2021 · 0 comments · Fixed by #3862
Assignees
Labels
bug investigating Issues being actively investigated

Comments

@anderseknert
Copy link
Member

Expected Behavior

As documented, configuration attributes accepting empty objects as values, when set with command line args and --set, should translate null values into an empty object.

Actual Behavior

Setting object attributes to null assigns them an actual null value.

Steps to Reproduce the Problem

Set any value that accepts and empty object to null.

opa run -s --set "services.test.headers=null"
 curl -s localhost:8181/v1/config | jq
{
  "result": {
    "default_authorization_decision": "/system/authz/allow",
    "default_decision": "/system/main",
    "labels": {
      "id": "5bae0115-664d-4eaa-bdfe-f6f880e26568",
      "version": "0.33.0-dev"
    },
    "services": {
      "test": {
        "headers": null
      }
    }
  }
}

Note how headers is of type object and should not be "nullable".

A more serious problem is how this essentially breaks the AWS metadata credentials options when not using a config file:

opa run -s 
--set "services.local.url=http://localhost" 
--set "services.local.credentials.s3_signing.environment_credentials=null" 
--set "bundles.authz.service=local"

Results in:

"Bundle load failed: request failed: a AWS credential service must be specified when S3 signing is enabled

Which is a consequence of null being treated literally as nil:

	if ap.AWSEnvironmentCredentials == nil && ap.AWSWebIdentityCredentials == nil && ap.AWSMetadataCredentials == nil {
		return nil, errors.New("a AWS credential service must be specified when S3 signing is enabled")
	}

Additional Info

Reported by @Sulbigar here.

@ashutosh-narkar ashutosh-narkar added the investigating Issues being actively investigated label Oct 4, 2021
@ashutosh-narkar ashutosh-narkar self-assigned this Oct 5, 2021
ashutosh-narkar added a commit to ashutosh-narkar/opa that referenced this issue Oct 6, 2021
This commit updates the parser for --set options
to return empty struct as return value when null
is specified. This is needed to set an empty object
with the CLI overrides for a null typed value.

Fixes: open-policy-agent#3846

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
ashutosh-narkar added a commit that referenced this issue Oct 6, 2021
This commit updates the parser for --set options
to return empty struct as return value when null
is specified. This is needed to set an empty object
with the CLI overrides for a null typed value.

Fixes: #3846

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
dolevf pushed a commit to dolevf/opa that referenced this issue Nov 4, 2021
This commit updates the parser for --set options
to return empty struct as return value when null
is specified. This is needed to set an empty object
with the CLI overrides for a null typed value.

Fixes: open-policy-agent#3846

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
Signed-off-by: Dolev Farhi <farhi.dolev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug investigating Issues being actively investigated
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants