Validate channel name exists on the instance when creating a channel #114
Labels
No labels
bug
devops
duplicate
enhancement
good first issue
layout
next major release
next minor release
question
research
testing
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lvl0/fedi-feed-router#114
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
When creating a channel, the name is typed free-hand and only validated for format — not for whether the community actually exists on the selected instance. A typo produces a channel that looks fine in the UI but fails at publish time.
Current state
app/Livewire/Channels.php::createChannel()validates:So
regexcatches malformed slugs anduniquecatches duplicates — but a well-formed name for a community that does not exist passes validation.The name doubles as the Lemmy community slug:
CreateChannelActioncopiesnameintochannel_id, which is used verbatim for community lookup at publish time (see the comment increateChannel()).Failure mode
LemmyApiService::resolveCommunityId()cannot resolve itExisting building block
app/Modules/Lemmy/Services/LemmyApiService.phpalready has what is needed:getCommunityId(string $communityName, string $token): int— queries the instance'scommunityendpoint by name and throws if not foundresolveCommunityId(string $channelId, string $token): int— handles the slug-vs-numeric caseSo existence checking is a matter of calling the existing method at create time, not writing new API code.
Two possible approaches
A. Validate on submit — keep the text input, call
getCommunityId()duringcreateChannel(), and surface a field error if the community is not found.addError()pattern already used forRuntimeExceptionB. Replace the input with a select — fetch the instance's communities and let the user pick.
updatedNewPlatformInstanceId()Recommendation
Worth considering A first, B second. A closes the correctness gap immediately with a small, well-tested change; B is the better experience but carries open questions (listing endpoint, pagination, scale, offline fallback) that deserve their own scoping.
Happy to be overruled if the select is wanted outright — noting the trade-off rather than deciding it.
Acceptance criteria
ChannelsTestcoverage still passesLemmyApiServicemocking notes in.claude/PLATFORM.md, since it takes a per-instance URL and cannot be container-resolvedRelated
Same create path hardened in #106 (channel_id integrity).