Skip to content

Commit 4f9923c

Browse files
committed
impl: prefer agent name over agent id in URI handler (2)
Error reporting should also prefer agent name over the agent id.
1 parent b54b74a commit 4f9923c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/kotlin/com/coder/gateway/util/LinkHandler.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,12 +339,12 @@ internal fun getMatchingAgent(
339339
}
340340

341341
if (agent == null) {
342-
if (!parameters.agentID().isNullOrBlank()) {
343-
throw IllegalArgumentException("The workspace \"${workspace.name}\" does not have an agent with ID \"${parameters.agentID()}\"")
344-
} else if (!parameters.agentName().isNullOrBlank()) {
342+
if (!parameters.agentName().isNullOrBlank()) {
345343
throw IllegalArgumentException(
346-
"The workspace \"${workspace.name}\"does not have an agent named \"${parameters.agentName()}\"",
344+
"The workspace \"${workspace.name}\" does not have an agent named \"${parameters.agentName()}\"",
347345
)
346+
} else if (!parameters.agentID().isNullOrBlank()) {
347+
throw IllegalArgumentException("The workspace \"${workspace.name}\" does not have an agent with ID \"${parameters.agentID()}\"")
348348
} else {
349349
throw MissingArgumentException(
350350
"Unable to determine which agent to connect to; one of \"$AGENT_NAME\" or \"$AGENT_ID\" must be set because the workspace \"${workspace.name}\" has more than one agent",

0 commit comments

Comments
 (0)