From 14ec86fdd987c185d62977c638db203b6e8d060b Mon Sep 17 00:00:00 2001
From: Marcin Tojek <marcin@coder.com>
Date: Thu, 13 Feb 2025 13:30:22 +0100
Subject: [PATCH 1/2] fix: support unlimited parameter options

---
 provider/parameter.go      |  1 -
 provider/parameter_test.go | 42 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/provider/parameter.go b/provider/parameter.go
index 00dd5f34..1345f4d6 100644
--- a/provider/parameter.go
+++ b/provider/parameter.go
@@ -237,7 +237,6 @@ func parameterDataSource() *schema.Resource {
 				Description: "Each `option` block defines a value for a user to select from.",
 				ForceNew:    true,
 				Optional:    true,
-				MaxItems:    64,
 				Elem: &schema.Resource{
 					Schema: map[string]*schema.Schema{
 						"name": {
diff --git a/provider/parameter_test.go b/provider/parameter_test.go
index b1f164a0..7bcea8fd 100644
--- a/provider/parameter_test.go
+++ b/provider/parameter_test.go
@@ -1,7 +1,9 @@
 package provider_test
 
 import (
+	"fmt"
 	"regexp"
+	"strings"
 	"testing"
 
 	"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
@@ -816,3 +818,43 @@ func TestValueValidatesType(t *testing.T) {
 		})
 	}
 }
+
+func TestParameterWithManyOptions(t *testing.T) {
+	t.Parallel()
+
+	const maxItemsInTest = 1024
+
+	var options strings.Builder
+	for i := 0; i < maxItemsInTest; i++ {
+		_, _ = options.WriteString(fmt.Sprintf(`option {
+					name = "%d"
+					value = "%d"
+				}
+`, i, i))
+	}
+
+	resource.Test(t, resource.TestCase{
+		ProviderFactories: coderFactory(),
+		IsUnitTest:        true,
+		Steps: []resource.TestStep{{
+			Config: fmt.Sprintf(`data "coder_parameter" "region" {
+				name = "Region"
+				type = "string"
+				%s
+			}`, options.String()),
+			Check: func(state *terraform.State) error {
+				require.Len(t, state.Modules, 1)
+				require.Len(t, state.Modules[0].Resources, 1)
+				param := state.Modules[0].Resources["data.coder_parameter.region"]
+
+				for i := 0; i < maxItemsInTest; i++ {
+					name, _ := param.Primary.Attributes[fmt.Sprintf("option.%d.name", i)]
+					value, _ := param.Primary.Attributes[fmt.Sprintf("option.%d.value", i)]
+					require.Equal(t, fmt.Sprintf("%d", i), name)
+					require.Equal(t, fmt.Sprintf("%d", i), value)
+				}
+				return nil
+			},
+		}},
+	})
+}

From 42f1f5874c54c391914ed3e87c1632bf021b67c9 Mon Sep 17 00:00:00 2001
From: Marcin Tojek <marcin@coder.com>
Date: Thu, 13 Feb 2025 13:35:05 +0100
Subject: [PATCH 2/2] fix: md

---
 docs/data-sources/parameter.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/data-sources/parameter.md b/docs/data-sources/parameter.md
index 4da9dac2..e46cf86d 100644
--- a/docs/data-sources/parameter.md
+++ b/docs/data-sources/parameter.md
@@ -147,7 +147,7 @@ data "coder_parameter" "home_volume_size" {
 - `ephemeral` (Boolean) The value of an ephemeral parameter will not be preserved between consecutive workspace builds.
 - `icon` (String) A URL to an icon that will display in the dashboard. View built-in icons [here](https://github.com/coder/coder/tree/main/site/static/icon). Use a built-in icon with `"${data.coder_workspace.me.access_url}/icon/<path>"`.
 - `mutable` (Boolean) Whether this value can be changed after workspace creation. This can be destructive for values like region, so use with caution!
-- `option` (Block List, Max: 64) Each `option` block defines a value for a user to select from. (see [below for nested schema](#nestedblock--option))
+- `option` (Block List) Each `option` block defines a value for a user to select from. (see [below for nested schema](#nestedblock--option))
 - `order` (Number) The order determines the position of a template parameter in the UI/CLI presentation. The lowest order is shown first and parameters with equal order are sorted by name (ascending order).
 - `type` (String) The type of this parameter. Must be one of: `"number"`, `"string"`, `"bool"`, or `"list(string)"`.
 - `validation` (Block List, Max: 1) Validate the input of a parameter. (see [below for nested schema](#nestedblock--validation))