fix: route unmapped colony slugs through correct API param at every call site#10
Merged
ColonistOne merged 1 commit intoTheColonyCC:masterfrom Apr 28, 2026
Conversation
…all site The hardcoded Colonies map only covers the original sub-communities; the platform routinely adds new ones (e.g. "builds", "lobby") that were silently passed through as raw slugs — producing HTTP 422 on CreatePost /JoinColony/LeaveColony and ?colony_id=<slug> on GetPosts/filter sites. - New colonyFilterParam helper picks ?colony_id=<uuid> for known slugs + UUID-shaped values, ?colony=<slug> for everything else (the API resolves the slug server-side). - New (*Client).resolveColonyUUID lazily fetches GET /colonies?limit=200 on first cache miss against Colonies, populates a mutex-protected per-Client slug→UUID cache, and returns a typed error with a sample of available colonies when the slug is genuinely unknown. - CreatePost / GetPosts filter / JoinColony / LeaveColony rewired to the new helpers. - legacy resolveColony kept for backward compat. Tests in slug_resolution_test.go (internal package — exercises unexported helpers): 8 functions covering known-slug + UUID fast paths, list-colonies-on-miss + cache reuse + concurrent fan-out, unknown-slug error shape, list-failure propagation, and malformed-row skipping. Package coverage 96.6% (up from 85% baseline). Mirrors colony-sdk-python #46 and colony-sdk-js #20. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment Thanks for integrating Codecov - We've got you covered ☂️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes the slug-resolution gap on every call site that takes a colony reference. The hardcoded
Coloniesmap only covers the original sub-communities; the platform routinely adds new ones (e.g.builds,lobby) that were silently passed through as raw slugs — producing HTTP 422 onCreatePost/JoinColony/LeaveColonyand?colony_id=<slug>onGetPosts/filter sites.colonyFilterParamhelper picks?colony_id=<uuid>for known slugs + UUID-shaped values,?colony=<slug>for everything else (the API resolves the slug server-side).(*Client).resolveColonyUUIDlazily fetchesGET /colonies?limit=200on first cache miss againstColonies, populates a mutex-protected per-Clientslug→UUID cache, and returns a typed error with a sample of available colonies when the slug is genuinely unknown.CreatePost/GetPostsfilter /JoinColony/LeaveColonyrewired to the new helpers.resolveColonykept for backward compat with downstream callers.Mirrors colony-sdk-python #46 and colony-sdk-js #20.
Test plan
go vet ./...cleangofmt -l .cleango test ./...— 8 new tests inslug_resolution_test.go(internal package, exercises unexported helpers): known-slug + UUID fast paths, list-colonies-on-miss, cache reuse, unknown-slug error shape with sample, list-failure error wrapping, malformed-row skippingTestJoinLeaveColonyupdated to mockGET /coloniessince"my-colony"now triggers a lookup🤖 Generated with Claude Code