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

Octopus API error: The Resource field is required. [] #217

Closed
mieliespoor opened this issue Jan 28, 2023 · 14 comments
Closed

Octopus API error: The Resource field is required. [] #217

mieliespoor opened this issue Jan 28, 2023 · 14 comments

Comments

@mieliespoor
Copy link

For some unknown reason, we are getting the following error back from the cli

Octopus API error: The Resource field is required. []

This is the the exact call we do, with parameter values

.\octopus.exe release create --project "package-update-downloader" --version "1.0.0-initial-commit.4177" --package-version "1.0.0-initial-commit.4177" --channel "Release" --release-notes "release 1.0.0-initial-commit.4177 commit -- 3c5541f4b71f9263929c7c1d241b6af05791ac05" --space "Default" --no-prompt

Note that the following were set as ENV vars. OCTOPUS_API_KEY and OCTOPUS_URL

I have run the above on Windows, but we see the same happening on Linux.

@benPearce1
Copy link
Contributor

Hi @mieliespoor

I tested the above command using v1.1 of the cli and the most recent version of Octopus Server, without issue.

There is a requirement of 2022.3 to be able to use some of functionality in the cli (these are release create, release deploy, runbook run).

@mieliespoor
Copy link
Author

mieliespoor commented Jan 30, 2023

We are on 2022.3 build 10847. We are thus on the correct minimum version. My main problem here is that the message returned is completely useless. I tried is on my own machine in various formats and keep getting that error, so something is most definitely broken in the cli.

@benPearce1
Copy link
Contributor

@mieliespoor you are correct that the error message is unhelpful. I have raised an issue #221 to specifically address the unhelpful messaging in this scenario.

In the meantime, the only workaround I can suggest is to upgrade your server to 2022.3 or later.

@mieliespoor
Copy link
Author

Apologies, I made a typo. We are running 2022.3.

@benPearce1
Copy link
Contributor

Are you able to provide me with exact server version number you are running and I will try to recreate your issue?

@mieliespoor
Copy link
Author

mieliespoor commented Feb 1, 2023

All I can see in Octopus is 2022.3 build 10847. Not sure what other version information there is.

{
  "Id": "systeminfo-octopusserver",
  "Version": "2022.3.10847",
  "OSVersion": "Linux 4.14.301-224.520.amzn2.x86_64 #1 SMP Fri Dec 9 09:57:03 UTC 2022",
  "WorkingSetBytes": 2322493440,
  "ClrVersion": ".NET 6.0.11",
  "ThreadCount": 88,
  "Uptime": "3.04:38:26",
  "Links": {
    "Self": "/api/serverstatus/system-info"
  }
}

image

@mieliespoor
Copy link
Author

Any feedback on this?

@benPearce1
Copy link
Contributor

Sorry for the slow response.
I haven't been able to recreate the error you are seeing, even running against the exact same server version you are using.
The artifact attached to this branch build of the cli, contains an updated cli which is an experiment on improving the debug output.
You will to update the version of octopus that you are running with the Windows exe contained in the zip file, and also need to add --debug to the command you are running. This should produce a stack trace of the failure point.

@benPearce1
Copy link
Contributor

@mieliespoor From the additional information provided in the support ticket you raised, it appears that it may be case-sensitivity when matching up the name of the project. This is only the case when the project query has been cached in memory, if the query has to go out to the database, it is dependant on the collation of the database.
This issue has been fixed in the most recent server versions.

Can you please try modifying your --project parameter to ensure the value exactly matches the name of the target project?

@mieliespoor
Copy link
Author

Hi Ben,
I have asked one of the guys in the team to do more tests and submit more information on the support ticket. One of the projects that was sent through on the support ticket had the casing issue and fixing that solved it. In this particular instance (the project in the first post), the project name has always been lower case. We will hopefully be able to give the additional info on the support ticket tomorrow.

@lhalleyvzc
Copy link

lhalleyvzc commented Apr 4, 2023

Sorry for the slow response. I haven't been able to recreate the error you are seeing, even running against the exact same server version you are using. The artifact attached to this branch build of the cli, contains an updated cli which is an experiment on improving the debug output. You will to update the version of octopus that you are running with the Windows exe contained in the zip file, and also need to add --debug to the command you are running. This should produce a stack trace of the failure point.

Here is an example of a command (same one @mieliespoor gave) which results in the "Octopus API error: The Resource field is required. []" error being seen with the --debug flag added:

octopus.exe release create --project "package-update-downloader" --version "1.0.0-initial-commit.4177" --package-version "1.0.0-initial-commit.4177" --channel "Release" --release-notes "release 1.0.0-initial-commit.4177 commit -- 3c5541f4b71f9263929c7c1d241b6af05791ac05" --space "Default" --no-prompt --debug

Outputted the following:

Octopus API error: The Resource field is required. []
/home/runner/work/cli/cli/pkg/executor/release.go:75 github.com/OctopusDeploy/cli/pkg/executor.releaseCreate()
/home/runner/work/cli/cli/pkg/executor/executor.go:48 github.com/OctopusDeploy/cli/pkg/executor.ProcessTasks()
/home/runner/work/cli/cli/pkg/cmd/release/create/create.go:268 github.com/OctopusDeploy/cli/pkg/cmd/release/create.createRun()
/home/runner/work/cli/cli/pkg/cmd/release/create/create.go:156 github.com/OctopusDeploy/cli/pkg/cmd/release/create.NewCmdCreate.func1()
/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:916 github.com/spf13/cobra.(*Command).execute()
/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:1044 github.com/spf13/cobra.(*Command).ExecuteC()
/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:968 github.com/spf13/cobra.(*Command).Execute()
/home/runner/work/cli/cli/cmd/octopus/main.go:75 main.main()
/opt/hostedtoolcache/go/1.19.6/x64/src/runtime/proc.go:250 runtime.main()
/opt/hostedtoolcache/go/1.19.6/x64/src/runtime/asm_amd64.s:1594 runtime.goexit()

I can see references to /opt/hostedtoolcache - @benPearce1 perhaps a caching issue like you suggested

@mieliespoor From the additional information provided in the support ticket you raised, it appears that it may be case-sensitivity when matching up the name of the project. This is only the case when the project query has been cached in memory, if the query has to go out to the database, it is dependant on the collation of the database. This issue has been fixed in the most recent server versions.

Can you please try modifying your --project parameter to ensure the value exactly matches the name of the target project?

Here is an example of a command where we ensure the --project parameter value exactly matches the name of the target project:

octopus.exe release create --project "<REDACTED>" --version 0.0.35-develop.35.temp --package-version 0.0.35-develop.35 --package="deployment.aws.ami:12.0.154" --channel Development --release-notes "auto created from build pipeline." --space "Default" --no-prompt

Which was successful

Successfully created release version 0.0.35-develop.35.temp using channel Development

View this release on Octopus Deploy: <REDACTED>

@benPearce1
Copy link
Contributor

@lhalleyvzc thanks for getting back to me.

From the stack trace in the error, I can see that this is caused by an error being returned from the Octopus API. This is still suggesting that one of the resource names in the command (project, channel or space) doesn't match the casing of the resource in the server.

@lhalleyvzc
Copy link

lhalleyvzc commented Apr 5, 2023

Hi @benPearce1 - I combed through that command after you mentioned checking

  1. project
  2. channel
  3. space

and turns out the --channel "Release" was causing the error.

After we switched it to an existing channel it worked.

I think once you guys improve that Octopus API error: The Resource field is required. [] error - this will be easily debugged 👍

Thanks!

@mieliespoor
Copy link
Author

I'm closing this since upgrading Octopus and the cli seemed to have fixed it for us. No point keeping this open anymore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants