Skip to content

Remove deprecated params from AuthorizePredicate#590

Merged
dahlia merged 1 commit intofedify-dev:2.0-maintenancefrom
dahlia:bugfix/remove-deprecated-authorize-predicate-params
Feb 26, 2026
Merged

Remove deprecated params from AuthorizePredicate#590
dahlia merged 1 commit intofedify-dev:2.0-maintenancefrom
dahlia:bugfix/remove-deprecated-authorize-predicate-params

Conversation

@dahlia
Copy link
Member

@dahlia dahlia commented Feb 26, 2026

Summary

AuthorizePredicate and ObjectAuthorizePredicate accepted signedKey and signedKeyOwner as third and fourth parameters since Fedify 0.7.0. These were deprecated in Fedify 1.5.0 in favor of calling RequestContext.getSignedKey() and RequestContext.getSignedKeyOwner() directly inside the predicate. They were intended to be removed in Fedify 2.0.0 but were mistakenly left in.

This omission caused a practical bug: the internal handler code (handleActor(), handleObject(), handleCollection(), authIfNeeded()) eagerly called getSignedKeyOwner() before every authorize predicate invocation, even when the predicate didn't use the value at all. Since getSignedKeyOwner() makes an unauthenticated HTTP request to fetch the remote key owner actor, this would throw an uncaught FetchError (and produce a 500 Internal Server Error) whenever the remote server has authorized fetch enabled and returns HTTP 401—as is the case with GoToSocial.

Changes

  • Removed signedKey and signedKeyOwner from AuthorizePredicate and ObjectAuthorizePredicate callback types.
  • Removed the CryptographicKey import from callback.ts (no longer referenced).
  • Removed the eager getSignedKey()/getSignedKeyOwner() calls and all associated deprecation-warning clone() logic from handleActor(), handleObject(), handleCollection(), and authIfNeeded().
  • Updated tests and the collections documentation example to call ctx.getSignedKey()/ctx.getSignedKeyOwner() directly.

Migration

Predicates that relied on the third and fourth parameters should now call ctx.getSignedKey() and ctx.getSignedKeyOwner() explicitly:

// Before
.authorize(async (ctx, identifier, signedKey, signedKeyOwner) => {
  if (signedKeyOwner == null) return false;
  return !await isBlocked(identifier, signedKeyOwner);
});

// After
.authorize(async (ctx, identifier) => {
  const signedKeyOwner = await ctx.getSignedKeyOwner();
  if (signedKeyOwner == null) return false;
  return !await isBlocked(identifier, signedKeyOwner);
});

Fixes #473

The third and fourth parameters of `AuthorizePredicate` and
`ObjectAuthorizePredicate` (`signedKey` and `signedKeyOwner`) were
deprecated in Fedify 1.5.0 in favor of `RequestContext.getSignedKey()`
and `RequestContext.getSignedKeyOwner()`.  They were not removed in
the Fedify 2.0.0 release as intended, which constitutes a bug: the
internal handler code was eagerly calling `getSignedKeyOwner()` before
invoking every authorize predicate, causing uncaught `FetchError`
exceptions (and HTTP 500 responses) when the remote server requires
authorized fetch and returns 401 for the key-owner lookup.

This commit removes the two parameters from both callback types and
strips the corresponding `getSignedKey()`/`getSignedKeyOwner()` calls
and deprecation-warning clone logic from `handleActor()`,
`handleObject()`, `handleCollection()`, and `authIfNeeded()`.
Predicates that need the signed key or key owner should now call
`ctx.getSignedKey()` and `ctx.getSignedKeyOwner()` directly.

Tests and the collections documentation example have been updated
accordingly.

fedify-dev#473

Co-Authored-By: Claude <claude@anthropic.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @dahlia, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a practical bug and refines the API by removing previously deprecated parameters from authorization predicates. By eliminating the eager fetching of signed keys and their owners, the change prevents unnecessary unauthenticated HTTP requests that could lead to server errors. This simplifies the predicate interfaces and ensures that key owner information is only retrieved when explicitly requested by the predicate, improving robustness and adherence to API design principles.

Highlights

  • Deprecated Parameter Removal: Removed the signedKey and signedKeyOwner parameters from AuthorizePredicate and ObjectAuthorizePredicate callback types, which were deprecated since Fedify 1.5.0.
  • Eager Fetching Fix: Eliminated the eager calls to getSignedKey() and getSignedKeyOwner() within internal handler code (handleActor, handleObject, handleCollection, authIfNeeded), resolving a bug where unauthenticated HTTP requests could cause 500 errors.
  • Codebase Modernization: Updated tests and documentation examples to directly call RequestContext.getSignedKey() and RequestContext.getSignedKeyOwner() when these values are needed within authorization predicates, aligning with the intended API usage.
Changelog
  • CHANGES.md
    • Removed the deprecated third and fourth parameters (signedKey and signedKeyOwner) from AuthorizePredicate and ObjectAuthorizePredicate.
    • Removed the internal handler code that eagerly called getSignedKey() and getSignedKeyOwner() before invoking the predicate.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@dahlia dahlia added type/bug Something isn't working component/federation Federation object related labels Feb 26, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes the deprecated signedKey and signedKeyOwner parameters from AuthorizePredicate and ObjectAuthorizePredicate. This addresses a bug caused by the eager fetching of signedKeyOwner, which could lead to unnecessary network requests and errors. The changes are applied consistently to the type definitions, internal handlers, tests, and documentation, resolving the issue as described.

@dahlia dahlia merged commit 8eb61d5 into fedify-dev:2.0-maintenance Feb 26, 2026
15 checks passed
@codecov
Copy link

codecov bot commented Feb 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

Files with missing lines Coverage Δ
packages/fedify/src/federation/handler.ts 81.83% <100.00%> (-1.59%) ⬇️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

component/federation Federation object related type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Having an AuthorizePredicate on an actor dispatcher breaks interoperability with GoToSocial

1 participant