Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the Fresh integration, visiting a non-existing actor in the browser produces a short 406 response instead of showing Fresh's 404 error page #34

Closed
jfietkau opened this issue Apr 4, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@jfietkau
Copy link

jfietkau commented Apr 4, 2024

Using Fedify and Fresh on Deno, all up to date versions. Whenever HTML is requested, the Federation object should let Fresh render the output, including error pages.

If I request a URI in the browser (or via curl with Accept: text/html) whose Fresh route returns a 404 error, and the URL maps to the registered actor dispatcher, the Federation handler appears to return a plain text 406 error in place of Fresh's 404 page. This should not happen.

Fresh middleware:

export const handler = integrateHandler(
  federation,
  (req, ctx) => undefined, // context data
);

Fresh handler:

export default async function UserPage(req: Request, ctx: RouteContext) {
  return ctx.renderNotFound();
}

Actor dispatcher:

federation.setActorDispatcher("/{handle}", async (ctx, handle, key) => {
  console.log("Invoked for:", handle);
  return null;
}

Testing shows that if application/activity+json is requested, the actor dispatcher is correctly invoked, returns null, and the client receives the HTML error page. If text/html is requested, the actor dispatcher is apparently not invoked, and the client receives a plain 406 Not acceptable error.

I hope the source of the problem is not some other part of my project, but this is the issue I am seeing.

@dahlia dahlia added the bug Something isn't working label Apr 5, 2024
@dahlia dahlia self-assigned this Apr 5, 2024
@dahlia
Copy link
Owner

dahlia commented Apr 5, 2024

The root cause is that the federation object negotiates the content before determining if the resource exists or not. It was a slight optimization, but I think it should be considered a bug. I'll fix it.

@dahlia dahlia closed this as completed in 7dcf4b2 Apr 5, 2024
@dahlia
Copy link
Owner

dahlia commented Apr 5, 2024

Fixed in 0.5.1!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants