Validate PlatformInstance on creation — check it is actually a Lemmy instance #132
Labels
No labels
bug
devops
duplicate
enhancement
good first issue
layout
next major release
next minor release
question
research
testing
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lvl0/fedi-feed-router#132
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adding a
PlatformInstancehas zero validation beyond the database constraints. You can enterhttps://google.comas a Lemmy instance URL and it is accepted without complaint. The failure surfaces much later — when channel creation tries to list communities or publishing tries to post — as an opaque connection error with no indication that the instance URL itself is wrong.Current state
PlatformInstancemodel hasurl,name,platform(enum),is_active— no validation beyondrequired|urlChannels.php:createChannel()) callsCommunityDirectory::forInstance($instance)which constructs aLemmyApiServicewith the raw URL and hitsGET /api/v3/community/listPlatformInstancecreation time at allDesign
Approach: NodeInfo check at create time
Forgejo/Lemmy instances expose a NodeInfo endpoint at
/.well-known/nodeinfo→/nodeinfo/2.0(or 2.1). The response includessoftware.name(e.g.,lemmy,forgejo) andsoftware.version. Checking this at instance creation time catches:What to validate
/.well-known/nodeinforeturns JSON with a link to a nodeinfo document. If not, surface: "This server does not appear to be a Lemmy instance."software.namecontainslemmy. If not, surface: "This server appears to be running {name}, not Lemmy."Where to validate
In
Channels.php/CreateChannelAction, whennewPlatformInstanceIdreferences a newly-created instance. Or better: in thePlatformInstancecreation path itself (onboarding flow + any future admin CRUD). The onboarding flow inOnboarding.phpalready creates instances — add validation there.Graceful degradation
If the NodeInfo endpoint is unreachable (temporary network issue, instance is down), the validation should:
This prevents a transient Lemmy outage from blocking instance setup entirely.
Tasks
NodeInfoService(or extendLemmyApiService) to resolve/.well-known/nodeinfo→ nodeinfo document →software.namePlatformInstancecreation in the onboarding flow (Onboarding.php)PlatformInstancecreation in any other entry point (channels page, admin panel if applicable)Edge cases
/.well-known/nodeinfo— should be skippableHttpFetchershould not reject these (already handled? confirm)software.name— the check should be a warning, not a hard block (or: pattern-match on known Lemmy names)Acceptance criteria
PlatformInstancewith a non-Lemmy URL is rejected with a clear field errorRelated