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

containerregistry:Task resource fails to create with InvalidRequestBody error #736

Closed
guidola opened this issue Apr 12, 2021 · 10 comments · Fixed by #743
Closed

containerregistry:Task resource fails to create with InvalidRequestBody error #736

guidola opened this issue Apr 12, 2021 · 10 comments · Fixed by #743
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed upstream/open-api

Comments

@guidola
Copy link

guidola commented Apr 12, 2021

Expected behavior

The resources would succeed in creating or, at least, prompt an error about the invalid present configuration if any.

Current behavior

The resource fails to create and a cryptic message re. not having a body or missing a discriminator is presented. Analyzing the resource properties there is no evident discriminator key so one might assume there is some internal problem inside the provider that is triggering a request with an empty body?

azure-native:containerregistry:Task SolutionBuildTask creating failed error: Code="InvalidRequestBody" Message="The request body is required for this request. Check if the body is not empty. If the request expects a polymorphic type, check if it has the discriminator property and is one of the described values." Target="request"

Steps to reproduce

  1. Create the following resource
    this.buildTask = new Task("BuildTask", {
            registryName: this.registry.name,
            resourceGroupName: args.resourceGroup.name,
            agentConfiguration: {
                cpu: 2
            },
            status: "Enabled",
            taskName: "buildTask",
            identity: {
                type: "SystemAssigned"
            },
            platform: {
                architecture: "amd64",
                os: "Linux"
            },
            step: {
                contextPath: "/dev/null"
            },
            credentials: {
                customRegistries: {
                    [`${args.registryA}.azurecr.io`]: { identity: "system" },
                    [`${args.registryB}.azurecr.io`]: { identity: "system" }
                }
            },
            timeout: 3600,
            trigger: {
            }
        }, {parent: this})

    NOTE: Both RegistryA and RegistryB variables are of type string

Context (Environment)

Affected feature

azure-native:containterregistry/Task

@guidola guidola added the kind/bug Some behavior is incorrect or out of spec label Apr 12, 2021
@mikhailshilkov
Copy link
Member

Thank you for reporting this @guidola

Could you please run the same deployment with debug options pulumi up --yes --skip-preview -v=9 --debug --logtostderr --logflow, locate the exact HTTP body that the provider is sending in the output, and attach it to the case? This way we will know what is going on.

Thank you in advance and sorry for the trouble!

@guidola
Copy link
Author

guidola commented Apr 12, 2021

I am running version 0.7.1 of the provider.

@guidola
Copy link
Author

guidola commented Apr 12, 2021

It seems the data is there on the put requests but getting this error still

[2021-04-12T11:55:20.007Z]     �[0m�[0mI0412 11:55:11.851222    2517 provider.go:1717] HTTP Response Begin GET [https://management.azure.com/subscriptions/redacted/tasks/buildSolution?api-version=2019-04-01 ===================================================
[2021-04-12T11:55:20.007Z]     �[0m�[0mHTTP/1.1 404 Not Found
[2021-04-12T11:55:20.007Z]     �[0m�[0mContent-Length: 269
[2021-04-12T11:55:20.007Z]     �[0m�[0mCache-Control: no-cache
[2021-04-12T11:55:20.007Z]     �[0m�[0mContent-Type: application/json; charset=utf-8
[2021-04-12T11:55:20.007Z]     �[0m�[0mDate: Mon, 12 Apr 2021 11:55:11 GMT
[2021-04-12T11:55:20.007Z]     �[0m�[0mExpires: -1
[2021-04-12T11:55:20.007Z]     �[0m�[0mPragma: no-cache
[2021-04-12T11:55:20.007Z]     �[0m�[0mStrict-Transport-Security: max-age=31536000; includeSubDomains
[2021-04-12T11:55:20.007Z]     �[0m�[0mX-Content-Type-Options: nosniff
[2021-04-12T11:55:20.007Z]     �[0m�[0mX-Ms-Failure-Cause: gateway
[2021-04-12T11:55:20.007Z]     �[0m�[0m{"error":{"code":"ResourceNotFound","message":"The Resource 'Microsoft.ContainerRegistry/registries/redacted/tasks/buildSolution' under resource group 'redacted' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"}}
[2021-04-12T11:55:20.008Z]     �[0m�[0m===================================================== HTTP Response End GET https://management.azure.com/subscriptions/redacted/tasks/buildSolution?api-version=2019-04-01
[2021-04-12T11:55:20.008Z]     �[0m�[0mI0412 11:55:11.851388    2517 provider.go:1694] HTTP Request Begin PUT https://management.azure.com/subscriptions/redacted/tasks/buildSolution?api-version=2019-04-01 ===================================================
[2021-04-12T11:55:20.008Z]     �[0m�[0mPUT /subscriptions/redacted/tasks/buildSolution?api-version=2019-04-01 HTTP/1.1
[2021-04-12T11:55:20.008Z]     �[0m�[0mHost: management.azure.com
[2021-04-12T11:55:20.008Z]     �[0m�[0mUser-Agent: Go/go1.15.8 (amd64-linux) go-autorest/v14.2.1 pulumi-azure-native/v0.7.1 pid-a90539d8-a7a6-5826-95c4-1fbef22d4b22
[2021-04-12T11:55:20.008Z]     �[0m�[0mContent-Length: 384
[2021-04-12T11:55:20.008Z]     �[0m�[0mContent-Type: application/json; charset=utf-8
[2021-04-12T11:55:20.008Z]     �[0m�[0m{"identity":{"type":"SystemAssigned"},"location":"NorthEurope","properties":{"agentConfiguration":{"cpu":2},"credentials":{"customRegistries":{"Tk8sTIK124SolutionRegistry.azurecr.io":{"identity":"system"},"teneotaks.azurecr.io":{"identity":"system"}}},"platform":{"architecture":"amd64","os":"Linux"},"status":"Enabled","step":{"contextPath":"/dev/null"},"timeout":3600,"trigger":{}}}
[2021-04-12T11:55:20.008Z]     �[0m�[0m===================================================== HTTP Request End PUT https://management.azure.com/subscriptions/redacted/tasks/buildSolution?api-version=2019-04-01
[2021-04-12T11:55:20.115Z]     �[0m�[0mI0412 11:55:17.242340    2517 provider.go:1717] HTTP Response Begin PUT [https://management.azure.com/subscriptions/redacted/tasks/buildSolution?api-version=2019-04-01 ===================================================
[2021-04-12T11:55:20.115Z]     �[0m�[0mHTTP/1.1 400 Bad Request
[2021-04-12T11:55:20.115Z]     �[0m�[0mContent-Length: 271
[2021-04-12T11:55:20.115Z]     �[0m�[0mCache-Control: no-cache
[2021-04-12T11:55:20.115Z]     �[0m�[0mContent-Type: application/json; charset=utf-8
[2021-04-12T11:55:20.115Z]     �[0m�[0mDate: Mon, 12 Apr 2021 11:55:17 GMT
[2021-04-12T11:55:20.115Z]     �[0m�[0mExpires: -1
[2021-04-12T11:55:20.115Z]     �[0m�[0mPragma: no-cache
[2021-04-12T11:55:20.115Z]     �[0m�[0mServer: nginx/1.15.10
[2021-04-12T11:55:20.115Z]     �[0m�[0mStrict-Transport-Security: max-age=31536000; includeSubDomains
[2021-04-12T11:55:20.115Z]     �[0m�[0mX-Content-Type-Options: nosniff
[2021-04-12T11:55:20.115Z]     �[0m�[0m{"error":{"code":"InvalidRequestBody","message":"The request body is required for this request. Check if the body is not empty. If the request expects a polymorphic type, check if it has the discriminator property and is one of the described values.","target":"request"}}

@guidola
Copy link
Author

guidola commented Apr 12, 2021

If you look at the spec for there are parameters for step that cannot be set in pulumi nor are populated with defaults by the provider. Might that be the issue? Seee https://docs.microsoft.com/en-us/rest/api/containerregistry/tasks/create#agentproperties

@mikhailshilkov
Copy link
Member

If you look at the spec for there are parameters for step that cannot be set in pulumi nor are populated with defaults by the provider. Might that be the issue?

Good point, that's likely the cause. The reason we don't generate three subtypes is that the type property is marked as read-only, so we assume it can't be set.

I submitted Azure/azure-rest-api-specs#13891

@mikhailshilkov mikhailshilkov added kind/bug Some behavior is incorrect or out of spec upstream/open-api and removed kind/bug Some behavior is incorrect or out of spec labels Apr 12, 2021
@guidola
Copy link
Author

guidola commented Apr 12, 2021

Thanks for the prompt reaction. I assume there is no workaround to get that type of resource created until the spec is fixed upstream correct?

@mikhailshilkov
Copy link
Member

Not in the short term, unfortunately. We'll likely make a fork of the specs repo to fix issues like this, but we need to understand the process and tradeoffs first.

@mikhailshilkov
Copy link
Member

mikhailshilkov commented Apr 13, 2021

It turns out this is fixed in v20190601preview: https://github.com/pulumi/pulumi-azure-native/blob/master/sdk/nodejs/containerregistry/v20190601preview/task.ts#L230

We aren't picking preview versions for top-level resources by default. Maybe we should make an exception here.

@guidola
Copy link
Author

guidola commented Apr 14, 2021

are you planning in doing a minor release of the provider any time soon to make the fix available?

@mikhailshilkov
Copy link
Member

yes, I'll do it within 1-2 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed upstream/open-api
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants