Skip to content

Commit 9780c1b

Browse files
fix(slimfaas): Increase job name max length from 12 to 30 characters (#267) (release)
* Initial plan * Update job name rules: increase max length from 12 to 30 characters Agent-Logs-Url: https://github.com/SlimPlanet/SlimFaas/sessions/93bb0e28-4c05-44a2-abc0-0e5df7ed0c15 Co-authored-by: guillaume-chervet <52236059+guillaume-chervet@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: guillaume-chervet <52236059+guillaume-chervet@users.noreply.github.com>
1 parent b8317ea commit 9780c1b

4 files changed

Lines changed: 14 additions & 12 deletions

File tree

src/SlimFaas/Endpoints/JobEndpoints.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ public static partial class JobEndpoints
1919

2020
private static bool IsValidFunctionName(string functionName, ILogger logger)
2121
{
22-
if (functionName.Length < 3 || functionName.Length > 12 || !FunctionNamePattern().IsMatch(functionName))
22+
if (functionName.Length < 3 || functionName.Length > 30 || !FunctionNamePattern().IsMatch(functionName))
2323
{
24-
logger.LogWarning("Invalid function name: {FunctionName}. Must match pattern [a-z0-9_-] and be between 3 and 12 characters", functionName);
24+
logger.LogWarning("Invalid function name: {FunctionName}. Must match pattern [a-z0-9_-] and be between 3 and 30 characters", functionName);
2525
return false;
2626
}
2727
return true;
@@ -67,7 +67,7 @@ private static async Task<IResult> CreateJob(
6767

6868
if (!IsValidFunctionName(functionName, logger))
6969
{
70-
return Results.BadRequest("Function name must match pattern [a-z0-9_-] and be between 3 and 12 characters");
70+
return Results.BadRequest("Function name must match pattern [a-z0-9_-] and be between 3 and 30 characters");
7171
}
7272

7373
CreateJob? createJob = await context.Request.ReadFromJsonAsync(
@@ -124,7 +124,7 @@ private static async Task<IResult> DeleteJob(
124124

125125
if (!IsValidFunctionName(functionName, logger))
126126
{
127-
return Results.BadRequest("Function name must match pattern [a-z0-9_-] and be between 3 and 12 characters");
127+
return Results.BadRequest("Function name must match pattern [a-z0-9_-] and be between 3 and 30 characters");
128128
}
129129

130130
bool isMessageComeFromNamespaceInternal =

src/SlimFaas/Endpoints/JobScheduleEndpoints.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ public static partial class JobScheduleEndpoints
2020

2121
private static bool IsValidFunctionName(string functionName, ILogger logger)
2222
{
23-
if (functionName.Length < 3 || functionName.Length > 12 || !FunctionNamePattern().IsMatch(functionName))
23+
if (functionName.Length < 3 || functionName.Length > 30 || !FunctionNamePattern().IsMatch(functionName))
2424
{
25-
logger.LogWarning("Invalid function name: {FunctionName}. Must match pattern [a-z0-9_-] and be between 3 and 12 characters", functionName);
25+
logger.LogWarning("Invalid function name: {FunctionName}. Must match pattern [a-z0-9_-] and be between 3 and 30 characters", functionName);
2626
return false;
2727
}
2828
return true;
@@ -70,7 +70,7 @@ private static async Task<IResult> CreateScheduleJob(
7070

7171
if (!IsValidFunctionName(functionName, logger))
7272
{
73-
return Results.BadRequest("Function name must match pattern [a-z0-9_-] and be between 3 and 12 characters");
73+
return Results.BadRequest("Function name must match pattern [a-z0-9_-] and be between 3 and 30 characters");
7474
}
7575

7676
if (scheduleJobService == null)
@@ -148,7 +148,7 @@ private static async Task<IResult> DeleteScheduleJob(
148148

149149
if (!IsValidFunctionName(functionName, logger))
150150
{
151-
return Results.BadRequest("Function name must match pattern [a-z0-9_-] and be between 3 and 12 characters");
151+
return Results.BadRequest("Function name must match pattern [a-z0-9_-] and be between 3 and 30 characters");
152152
}
153153

154154
bool isMessageComeFromNamespaceInternal =

tests/SlimFaas.Tests/Jobs/JobEndpointsTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public async Task RunJob_Returns_expected_status(string path,
102102

103103
[Theory(DisplayName = "POST /job/{name} – retourne 400 si le nom de fonction est invalide")]
104104
[InlineData("/job/ab")]
105-
[InlineData("/job/abcdefghijklm")]
105+
[InlineData("/job/abcdefghijklmnopqrstuvwxyz12345")]
106106
[InlineData("/job/test.func")]
107107
[InlineData("/job/test func")]
108108
[InlineData("/job/test@func")]
@@ -130,6 +130,7 @@ public async Task CreateJob_Returns_400_When_FunctionName_Invalid(string path)
130130
[Theory(DisplayName = "POST /job/{name} – accepte les noms valides")]
131131
[InlineData("/job/abc")]
132132
[InlineData("/job/abcdefghijkl")]
133+
[InlineData("/job/abcdefghijklmnopqrstuvwxyz1234")]
133134
[InlineData("/job/test-func")]
134135
[InlineData("/job/my-app")]
135136
[InlineData("/job/daisy")]
@@ -225,7 +226,7 @@ public async Task DeleteJob_Returns_expected_status(string path,
225226

226227
[Theory(DisplayName = "DELETE /job/{name}/{id} – retourne 400 si le nom de fonction est invalide")]
227228
[InlineData("/job/ab/123")]
228-
[InlineData("/job/abcdefghijklm/123")]
229+
[InlineData("/job/abcdefghijklmnopqrstuvwxyz12345/123")]
229230
public async Task DeleteJob_Returns_400_When_FunctionName_Invalid(string path)
230231
{
231232
(IHost host, Mock<IJobService> jobSvc, _) = await BuildHostAsync(jobServiceMock =>

tests/SlimFaas.Tests/Jobs/JobScheduleEndpointsTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ await BuildHostAsync(svc =>
137137

138138
[Theory(DisplayName = "POST /job-schedules/{name} – retourne 400 si le nom de fonction est invalide")]
139139
[InlineData("/job-schedules/ab")]
140-
[InlineData("/job-schedules/abcdefghijklm")]
140+
[InlineData("/job-schedules/abcdefghijklmnopqrstuvwxyz12345")]
141141
[InlineData("/job-schedules/test.func")]
142142
[InlineData("/job-schedules/test func")]
143143
[InlineData("/job-schedules/test@func")]
@@ -166,6 +166,7 @@ await BuildHostAsync(svc =>
166166
[Theory(DisplayName = "POST /job-schedules/{name} – accepte les noms valides")]
167167
[InlineData("/job-schedules/abc")]
168168
[InlineData("/job-schedules/abcdefghijkl")]
169+
[InlineData("/job-schedules/abcdefghijklmnopqrstuvwxyz1234")]
169170
[InlineData("/job-schedules/test-func")]
170171
[InlineData("/job-schedules/my-app")]
171172
[InlineData("/job-schedules/daisy")]
@@ -276,7 +277,7 @@ await BuildHostAsync(svc =>
276277

277278
[Theory(DisplayName = "DELETE /job-schedules/{name}/{id} – retourne 400 si le nom de fonction est invalide")]
278279
[InlineData("/job-schedules/ab/sid")]
279-
[InlineData("/job-schedules/abcdefghijklm/sid")]
280+
[InlineData("/job-schedules/abcdefghijklmnopqrstuvwxyz12345/sid")]
280281
public async Task DeleteSchedule_Returns_400_When_FunctionName_Invalid(string path)
281282
{
282283
(IHost host, Mock<IScheduleJobService> schedSvc, _) =

0 commit comments

Comments
 (0)