Skip to content

Commit 2defdcf

Browse files
committed
fix: agentapi: fix subpath version off-by-one error
1 parent ada586f commit 2defdcf

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

registry/coder/modules/agentapi/main.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,28 +174,28 @@ describe("agentapi", async () => {
174174
const cases = [
175175
{
176176
moduleVariables: {
177-
agentapi_version: "v0.3.2",
177+
agentapi_version: "v0.3.1",
178178
agentapi_subdomain: "false",
179179
},
180180
shouldThrow: "",
181181
},
182182
{
183183
moduleVariables: {
184-
agentapi_version: "v0.3.2",
184+
agentapi_version: "v0.3.1",
185185
agentapi_subdomain: "true",
186186
},
187187
shouldThrow: "",
188188
},
189189
{
190190
moduleVariables: {
191-
agentapi_version: "v0.3.1",
191+
agentapi_version: "v0.3.0",
192192
agentapi_subdomain: "false",
193193
},
194-
shouldThrow: "Running with subdomain = false is only supported by agentapi >= v0.3.2.",
194+
shouldThrow: "Running with subdomain = false is only supported by agentapi >= v0.3.1.",
195195
},
196196
{
197197
moduleVariables: {
198-
agentapi_version: "v0.3.1",
198+
agentapi_version: "v0.3.0",
199199
agentapi_subdomain: "true",
200200
},
201201
shouldThrow: "",

registry/coder/modules/agentapi/main.tf

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ variable "install_agentapi" {
117117
variable "agentapi_version" {
118118
type = string
119119
description = "The version of AgentAPI to install."
120-
default = "v0.3.2"
120+
default = "v0.3.1"
121121
}
122122

123123
variable "agentapi_port" {
@@ -127,8 +127,8 @@ variable "agentapi_port" {
127127
}
128128

129129
locals {
130-
# agentapi_subdomain_false_min_version_expr matches a semantic version >= v0.3.2.
131-
agentapi_subdomain_false_min_version_expr = "^v(0\\.(3\\.[2-9]+|[4-9]+\\.\\d+)|[1-9]\\d*\\.\\d+\\.\\d+)$"
130+
# agentapi_subdomain_false_min_version_expr matches a semantic version >= v0.3.1.
131+
agentapi_subdomain_false_min_version_expr = "^v(0\\.(3\\.[1-9]+|[4-9]+\\.\\d+)|[1-9]\\d*\\.\\d+\\.\\d+)$"
132132
}
133133

134134
variable "agentapi_subdomain" {
@@ -138,10 +138,12 @@ variable "agentapi_subdomain" {
138138
validation {
139139
condition = var.agentapi_subdomain || (
140140
# If version doesn't look like a valid semantic version, just allow it.
141-
!can(regex("^v\\d+\\.\\d+\\.\\d+$", var.agentapi_version))
142-
|| can(regex(local.agentapi_subdomain_false_min_version_expr, var.agentapi_version))
141+
# Note that boolean operators do not short-circuit in Terraform.
142+
can(regex("^v\\d+\\.\\d+\\.\\d+$", var.agentapi_version)) ?
143+
can(regex(local.agentapi_subdomain_false_min_version_expr, var.agentapi_version)) :
144+
true
143145
)
144-
error_message = "Running with subdomain = false is only supported by agentapi >= v0.3.2."
146+
error_message = "Running with subdomain = false is only supported by agentapi >= v0.3.1."
145147
}
146148
}
147149

@@ -161,7 +163,7 @@ locals {
161163
agentapi_wait_for_start_script_b64 = base64encode(file("${path.module}/scripts/agentapi-wait-for-start.sh"))
162164
// Chat base path is only set if not using a subdomain.
163165
// NOTE:
164-
// - This requires agentapi version >= v0.3.2.
166+
// - This requires agentapi version >= v0.3.1.
165167
// - As CODER_WORKSPACE_AGENT_NAME is a recent addition we use agent ID
166168
// for backward compatibility.
167169
agentapi_chat_base_path = var.agentapi_subdomain ? "" : "/@${data.coder_workspace_owner.me.name}/${data.coder_workspace.me.name}.${var.agent_id}/apps/${var.web_app_slug}/chat"

0 commit comments

Comments
 (0)