Skip to content
2 changes: 1 addition & 1 deletion src/Agent.Worker/TaskCommandExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ public void Execute(IExecutionContext context, Command command)
var endpoint = context.Endpoints.Find(a => a.Id == endpointId);
if (endpoint == null)
{
throw new ArgumentNullException(StringUtil.Loc("InvalidEndpointId"));
throw new ArgumentNullException(StringUtil.Loc("ServiceConnectionNotDeclared", endpointId));
}

if (String.Equals(field, "url", StringComparison.OrdinalIgnoreCase))
Expand Down
1 change: 1 addition & 0 deletions src/Misc/layoutbin/en-US/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@
"ServerUrl": "server URL",
"ServiceAlreadyExists": "The service already exists: {0}, it will be replaced",
"ServiceConfigured": "Service {0} successfully configured",
"ServiceConnectionNotDeclared": "Service connection with id '{0}' is not declared in the pipeline job and therefore can't be referenced in task.setendpoint commands.",
"ServiceDelayedStartOptionSet": "Service {0} successfully set to delayed auto start",
"ServiceInstalled": "Service {0} successfully installed",
"ServiceLockErrorRetry": "Service DB lock failed with code {0}. Retrying after {1} seconds...",
Expand Down
19 changes: 19 additions & 0 deletions src/Test/L0/Worker/TaskCommandExtensionL0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,25 @@ public void SetEndpointInvalidEndpointId()
}
}

[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Worker")]
public void SetEndpointServiceConnectionNotDeclared()
{
using (var _hc = SetupMocks())
{
TaskCommandExtension commandExtension = new TaskCommandExtension();
var cmd = new Command("task", "setEndpoint");
cmd.Data = "http://example.com/";
cmd.Properties.Add("field", "url");
// Use a valid GUID that is not in the Endpoints list (SetupMocks only adds Guid.Empty)
var testEndpointId = "12345678-1234-1234-1234-123456789012";
cmd.Properties.Add("id", testEndpointId);

Assert.Throws<ArgumentNullException>(() => commandExtension.ProcessCommand(_ec.Object, cmd));
}
}

[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Worker")]
Expand Down
Loading