Skip to content

generateActors throws on a stored host the runtime cannot parse #84

Description

@dahlia

generateActors builds a Fedify context from the instance's stored host:

const fedCtx = ctx.federation.createContext(
  new URL(`${ctx.rootOrigin.protocol}//${host}`),
  undefined,
);

new URL() throws if that host is not a parseable authority, and the call sits inside the transaction, so the failure surfaces as an unhandled GraphQL error rather than one of the results the mutation declares.

A host like that can be there. The slug rule only constrains shape, and whether an xn-- label is decodable Punycode is answered by the runtime's own ICU: a slug accepted on one Node build composes a host another refuses to parse. createInstance guards against this at creation time, but only against the runtime it is running on, so an instance created before a Node upgrade, or on a different machine, can outlive the guard. Rows predating the tightened slug constraint are another way in.

generateActors is served on the control surface, so reaching it does not depend on the instance's own host parsing. A member of the affected instance calling it is enough.

The startup scan already treats such a host as something to report rather than to crash on: findStrandedInstances in packages/drfed/src/serving.ts guards with URL.canParse and lists the instance as unreachable. The same guard here would let the mutation return a declared error instead of throwing. Whether that should be InstanceNotFound or a new member of CreateActorsErrorType is worth deciding rather than assuming.

Found by review while fixing the ICU dependency in #83.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Fields

    Priority

    None yet

    Effort

    None yet

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions