Skip to content

Bug [jetbrains-gateway]: Errors produced when jetbrains_ide_versions aren't a covering set #22

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

Open
angrycub opened this issue Apr 28, 2025 · 1 comment

Comments

@angrycub
Copy link

angrycub commented Apr 28, 2025

Issue

When I specify jetbrains_ide_versions, it causes the template to throw errors unless all of the versions are set in the template. As a user, I would prefer to only set versions for the specific versions that I need to make explicit.

For example, if I only need a specific version of IntelliJ IDEA Ultimate, I would like to have my variables set like the following:

module "jetbrains_gateway" {
  jetbrains_ides = ["IU"]
  default        = "IU"
  latest         = false
  jetbrains_ide_versions = {
    "IU" = {
      build_number = "243.26053.27"
      version      = "2024.3"
    }
  }
}

However, if I do that currently, I receive three errors per product identifier, even for the ones I do not have configured, like the following:

╷
│ Error: Invalid index
│ 
│   on jetbrains-gateway/main.tf line 186, in locals:
│  186:       build_number  = var.jetbrains_ide_versions["GO"].build_number,
│     ├────────────────
│     │ var.jetbrains_ide_versions is map of object with 1 element
│ 
│ The given key does not identify an element in this collection value.
╵
╷
│ Error: Invalid index
│ 
│   on jetbrains-gateway/main.tf line 187, in locals:
│  187:       download_link = "${var.download_base_link}/go/goland-${var.jetbrains_ide_versions["GO"].version}.tar.gz"
│     ├────────────────
│     │ var.jetbrains_ide_versions is map of object with 1 element
│ 
│ The given key does not identify an element in this collection value.
╵
╷
│ Error: Invalid index
│ 
│   on jetbrains-gateway/main.tf line 188, in locals:
│  188:       version       = var.jetbrains_ide_versions["GO"].version
│     ├────────────────
│     │ var.jetbrains_ide_versions is map of object with 1 element
│ 
│ The given key does not identify an element in this collection value.
╵

This looks to be related to the lines like this, which would be attempting to access variables that don't exist in the replaced set of values.

Potential remediations

If we move the current default list of IDE versions to a local, we could then merge in a user-supplied jetbrains_ide_versions to create a fully-covering map. Perhaps we could do the same thing with the default list of IDEs; however in that case, we might want to step on the defaults if the template admins provides a specific list of IDEs to show.

The super-sized fix for this would fetch the output for the Jetbrains product API, cache the values as a local latest which would be put in amber for each version of the module. This has the side benefit of providing an object that we could merge both user supplied and freshly-fetched latest version data from the product API into the cached data. That object would also contain information about all of the platform specific download URLs. We still have to maintain a separate object to hold the product code, full IDE names, and icons to use.

Externalizing the data as JSON files and loading them in from the module also makes them a bit more editable/loadable without having to edit the template source anytime we want to update the in-built defaults.

@angrycub
Copy link
Author

We can see interest in multi-architecture downloads in PR coder/modules#452

@Parkreiner Parkreiner transferred this issue from coder/modules May 8, 2025
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

1 participant