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

(fix): Checking request has parameter before reading them #179

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dix
Copy link

@dix dix commented Jun 14, 2024

Hi,

The list method of basicRepository allows us not passing any parameter/argument for our request.

But the Client, before performing the request, will check is the request is scape scoped by reading its parameters, using the isSpaceScopedRequest method of SpaceScopedRequest.

This method doesn't check that the parameters are not empty (= command is defined) before trying to access them; which result in a runtime error :

/xxx/node_modules/@octopusdeploy/api-client/dist/spaceScopedRequest.js:5
    return "spaceName" in command;
                       ^
TypeError: Cannot use 'in' operator to search for 'spaceName' in undefined
    at isSpaceScopedRequest (/xxx/node_modules/@octopusdeploy/api-client/dist/spaceScopedRequest.js:5:24)
    at Client.<anonymous> (/xxx/node_modules/@octopusdeploy/api-client/dist/client.js:240:76)

I encountered the issue while calling list without parameters on a SpaceRepository instance ; while trying to retrieve Spaces without any criterion.

The fix proposal is to check that the request do have parameters before accessing them; avoiding a runtime error when there isn't any parameter.

@CLAassistant
Copy link

CLAassistant commented Jun 14, 2024

CLA assistant check
All committers have signed the CLA.

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

Successfully merging this pull request may close these issues.

2 participants