Skip to content

Trim Bluesky social follow targets#735

Merged
ralyodio merged 1 commit into
profullstack:masterfrom
rissrice2105-agent:codex/sh1pt-social-follow-trim
Jun 14, 2026
Merged

Trim Bluesky social follow targets#735
ralyodio merged 1 commit into
profullstack:masterfrom
rissrice2105-agent:codex/sh1pt-social-follow-trim

Conversation

@rissrice2105-agent

Copy link
Copy Markdown
Contributor

Fixes #734.

Summary

  • Trim social follow target input before URL parsing and bare Bluesky handle fallback
  • Preserve existing parsing behavior for profile/follows/followers sources
  • Add regression coverage for whitespace-padded Bluesky handles and URLs

Verification

  • corepack pnpm vitest run packages/cli/src/social-follow.test.ts

Note

  • corepack pnpm --filter @profullstack/sh1pt typecheck still fails on pre-existing workspace resolution/type errors unrelated to this patch, including unresolved @profullstack/sh1pt-core, @profullstack/sh1pt-actions-fleet-core, and @profullstack/sh1pt-openapi/*.

@greptile-apps

greptile-apps Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a bug where leading/trailing whitespace on a Bluesky follow target caused parseSocialFollowTarget to misparse bare handles or throw unexpectedly. The fix is a single input.trim() call placed before both the URL constructor and the bare-handle detection logic.

  • social-follow.ts: One-line addition of input = input.trim() at the top of parseSocialFollowTarget; correctly gates all downstream parsing paths.
  • social-follow.test.ts: New test exercises whitespace-padded handles (with explicit platform) and whitespace-padded URLs; the auto-detected bare-handle path (alice.bsky.social without @ or explicit platform) is not covered by the new cases.

Confidence Score: 5/5

Safe to merge — the change is a single defensive trim with no behavioral side-effects beyond the intended fix.

The production change is one line that cannot regress any existing behavior; it only widens the set of accepted inputs. The sole gap is a missing test case for the auto-detected bare-handle trim path, which is a coverage concern rather than a functional defect.

No files require special attention; the optional additional test case in social-follow.test.ts would close the remaining coverage gap.

Important Files Changed

Filename Overview
packages/cli/src/social-follow.ts Adds a single input = input.trim() at the top of parseSocialFollowTarget; correctly placed before URL parsing and bare-handle detection, no side-effects.
packages/cli/src/social-follow.test.ts New test covers whitespace-padded handle (with explicit platform) and whitespace-padded URL; the auto-detected bare-handle trim path (no explicit platform, no @ prefix) is not exercised.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["parseSocialFollowTarget(input, explicitPlatform)"] --> B["input = input.trim() NEW"]
    B --> C["normalizePlatform(explicitPlatform)"]
    C --> D{platform and not bluesky?}
    D -- Yes --> E["throw: unsupported platform"]
    D -- No --> F["new URL(input)"]
    F -- success --> G{host === bsky.app?}
    G -- No --> H["throw: unsupported URL host"]
    G -- Yes --> I["parse /profile/:actor/:tab segments"]
    I --> J["return { platform, actor, source }"]
    F -- throws --> K{platform === bluesky OR looksLikeBlueskyActor?}
    K -- Yes --> L["return { platform: bluesky, actor: input.replace(@,''), source: profile }"]
    K -- No --> M["throw: expected social account URL"]
Loading

Reviews (1): Last reviewed commit: "Trim social follow targets" | Re-trigger Greptile

Comment on lines +25 to +36
it('trims whitespace around Bluesky handles and URLs', () => {
expect(parseSocialFollowTarget(' @alice.bsky.social ', 'bluesky')).toEqual({
platform: 'bluesky',
actor: 'alice.bsky.social',
source: 'profile',
});
expect(parseSocialFollowTarget(' https://bsky.app/profile/source.bsky.social/followers ')).toEqual({
platform: 'bluesky',
actor: 'source.bsky.social',
source: 'followers',
});
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 The new test block covers trimming for (a) a handle with an explicit 'bluesky' platform and (b) a URL. It misses the auto-detection path where no explicit platform is passed and looksLikeBlueskyActor is relied upon — e.g., alice.bsky.social (no @, no explicit platform). Before the fix that input would slip through trimming and the regex in looksLikeBlueskyActor would reject it due to the leading space; the fix cures it, but there is no regression test for it. Adding one case here would close the coverage gap.

Suggested change
it('trims whitespace around Bluesky handles and URLs', () => {
expect(parseSocialFollowTarget(' @alice.bsky.social ', 'bluesky')).toEqual({
platform: 'bluesky',
actor: 'alice.bsky.social',
source: 'profile',
});
expect(parseSocialFollowTarget(' https://bsky.app/profile/source.bsky.social/followers ')).toEqual({
platform: 'bluesky',
actor: 'source.bsky.social',
source: 'followers',
});
});
it('trims whitespace around Bluesky handles and URLs', () => {
expect(parseSocialFollowTarget(' @alice.bsky.social ', 'bluesky')).toEqual({
platform: 'bluesky',
actor: 'alice.bsky.social',
source: 'profile',
});
// auto-detected bare handle (no @ prefix, no explicit platform)
expect(parseSocialFollowTarget(' alice.bsky.social ')).toEqual({
platform: 'bluesky',
actor: 'alice.bsky.social',
source: 'profile',
});
expect(parseSocialFollowTarget(' https://bsky.app/profile/source.bsky.social/followers ')).toEqual({
platform: 'bluesky',
actor: 'source.bsky.social',
source: 'followers',
});
});

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@rissrice2105-agent

Copy link
Copy Markdown
Contributor Author

CI is green for PR #735.

Verification:

  • corepack pnpm vitest run packages/cli/src/social-follow.test.ts

Note: package typecheck still hits pre-existing workspace resolution/type errors unrelated to this patch, as documented in the PR body. uGig invoice evidence has been sent for this PR.

@github-actions

Copy link
Copy Markdown

🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: git fetch upstream master && git rebase upstream/master.

6 similar comments
@github-actions

Copy link
Copy Markdown

🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: git fetch upstream master && git rebase upstream/master.

@github-actions

Copy link
Copy Markdown

🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: git fetch upstream master && git rebase upstream/master.

@github-actions

Copy link
Copy Markdown

🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: git fetch upstream master && git rebase upstream/master.

@github-actions

Copy link
Copy Markdown

🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: git fetch upstream master && git rebase upstream/master.

@github-actions

Copy link
Copy Markdown

🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: git fetch upstream master && git rebase upstream/master.

@github-actions

Copy link
Copy Markdown

🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: git fetch upstream master && git rebase upstream/master.

@ralyodio ralyodio merged commit 9b8f0c1 into profullstack:master Jun 14, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

social follow rejects Bluesky handles with surrounding whitespace

2 participants