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

Incorrect Parameters For Command With Same Name As Job #191

Open
dsanders11 opened this issue Aug 23, 2023 · 4 comments
Open

Incorrect Parameters For Command With Same Name As Job #191

dsanders11 opened this issue Aug 23, 2023 · 4 comments

Comments

@dsanders11
Copy link

dsanders11 commented Aug 23, 2023

If a command and a job have the same name, the language server will use the parameters from the job, for the command's parameters, leading to incorrect errors.

It looks like the root cause are these chunks of code, where the parameters are looked up for a command first, then a job, so if they have the same name, it falls through and returns the parameters for the job. It looks like that code needs to have a better understanding of what type the entity actually is, rather than just looking it up by name, since the name can refer to either a command or a job.

Warning

This issue exists in at least two spots, GetDefinedParams and GetOrbDefinedParams, but I did not exhaustively check for others. I'm seeing this error specifically with commands from an orb.

func (doc *YamlDocument) GetDefinedParams(entityName string, cache *utils.Cache) map[string]ast.Parameter {
var definedParams map[string]ast.Parameter
if command, ok := doc.Commands[entityName]; ok {
definedParams = command.Parameters
}
if job, ok := doc.Jobs[entityName]; ok {
definedParams = job.Parameters
}
if doc.IsOrbCommand(entityName, cache) || doc.IsOrbJob(entityName, cache) {
return doc.GetOrbDefinedParams(entityName, cache)
}
return definedParams
}

func (doc *YamlDocument) GetOrbDefinedParams(entityName string, cache *utils.Cache) map[string]ast.Parameter {
var definedParams map[string]ast.Parameter
splittedName := strings.Split(entityName, "/")
orbName := splittedName[0]
commandOrJob := splittedName[1]
orbInfo, err := doc.GetOrFetchOrbInfo(doc.Orbs[orbName], cache)
if err != nil {
return definedParams
}
if command, ok := orbInfo.Commands[commandOrJob]; ok {
definedParams = command.Parameters
}
if job, ok := orbInfo.Jobs[commandOrJob]; ok {
definedParams = job.Parameters
}
return definedParams
}

@loderunner
Copy link
Contributor

Thanks for reporting this!

Would it be possible for you to provide a YAML config file that triggers this issue?

@dsanders11
Copy link
Author

This is the config where the issue was noticed with the VS Code extension: https://github.com/electron/forge/blob/main/.circleci/config.yml

@andrealiz-saildrone
Copy link

I just ran into this using the aws-s3 orb. Are there any updates on this? I have a workaround but would be nice to utilize the orb fully.

@ambroselittle
Copy link

Still an issue it seems.

VS Code using the extension:
image

This wouldn't be so problematic if there were a way to suppress errors/warning per line. Put an "idea" in here for that. Let me know if it should rather be an issue here, tho.

Would love to get my config file "problem" free. It's the OCD.. :D

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

4 participants