Skip to content

Commit 44b1711

Browse files
committed
Add validation for empty identifier in mapActorAlias
Ensured that the `identifier` parameter in `mapActorAlias()` is not an empty string. Added a regression test to verify this validation. #753 (comment) Assisted-by: Gemini CLI:gemini-3-flash-preview Assisted-by: Codex:gpt-5.5
1 parent 2334b6d commit 44b1711

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

packages/fedify/src/federation/builder.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ test("FederationBuilder", async (t) => {
5353
RouterError,
5454
'Actor alias path "/actor" conflicts with existing route "actorAlias:instance".',
5555
);
56+
assertThrows(
57+
() =>
58+
createFederationBuilder<string>()
59+
.setActorDispatcher("/users/{identifier}", actorDispatcher)
60+
.mapActorAlias("/actor", ""),
61+
RouterError,
62+
"Identifier cannot be empty.",
63+
);
5664
builder.setActorDispatcher("/users/{identifier}", actorDispatcher)
5765
.mapActorAlias("/actor", "instance");
5866

packages/fedify/src/federation/builder.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,9 @@ export class FederationBuilderImpl<TContextData>
525525
return setters;
526526
},
527527
mapActorAlias: (path: `/${string}`, identifier: string) => {
528+
if (identifier === "") {
529+
throw new RouterError("Identifier cannot be empty.");
530+
}
528531
if (this.router.has(`${ACTOR_ALIAS_PREFIX}${identifier}`)) {
529532
throw new RouterError(
530533
`Actor alias for "${identifier}" already set.`,

0 commit comments

Comments
 (0)