You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: canonicalize Last.fm connect URL host in production - #195
This change adds validation to the Last.fm link origin-resolution logic, rejecting legacy nexus.lucassantana.tech and non-HTTP(S) URLs while falling back to WEBAPP_REDIRECT_URI when appropriate, alongside documentation clarifications and comprehensive test coverage.
Changes
Cohort / File(s)
Summary
Documentation Updates CHANGELOG.md, README.md
Clarified origin rejection behavior for legacy nexus and non-HTTP(S) origins during connect URL generation. Expanded environment variable descriptions for WEBAPP_REDIRECT_URI and WEBAPP_BACKEND_URL to document canonical production URL requirements.
Updated getAbsoluteOrigin function to validate protocol (http/https only) and reject legacy nexus.lucassantana.tech hostname before returning origin, preventing invalid origins in production embeds.
Test Coverage packages/bot/src/functions/general/commands/lastfm.spec.ts
Added tests verifying fallback behavior when backend URL is legacy or invalid, configuration errors when both URLs are invalid, and normalization behavior with invalid origins excluded.
Sequence Diagram
sequenceDiagram
participant Client
participant Bot as Bot Command Handler
participant Validator as getAbsoluteOrigin()
participant Backend as WEBAPP_BACKEND_URL
participant Redirect as WEBAPP_REDIRECT_URI
Client->>Bot: Request Last.fm connect link
Bot->>Validator: Validate WEBAPP_BACKEND_URL
Validator->>Backend: Parse and check protocol & hostname
alt Valid (http/https & not nexus)
Validator-->>Bot: Return backend origin
else Invalid
Validator-->>Bot: Return null
Bot->>Validator: Validate WEBAPP_REDIRECT_URI
Validator->>Redirect: Parse and check protocol & hostname
alt Valid (http/https & not nexus)
Validator-->>Bot: Return redirect origin
else Invalid
Validator-->>Bot: Return null (config error)
end
end
Bot-->>Client: Connect URL or error embed
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.
Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name
Status
Explanation
Title check
✅ Passed
The title accurately describes the main change: hardening URL origin validation and rejecting legacy nexus origins for Last.fm connect URL generation in production.
Description Check
✅ Passed
Check skipped - CodeRabbit’s high-level summary is enabled.
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
📝 Generate docstrings (stacked PR)
📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
Create PR with unit tests
Post copyable unit tests in a comment
Commit unit tests in branch fix/lastfm-canonical-prod-url
📝 Coding Plan
Generate coding plan for human review comments
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
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
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
/lastfm linkURL origin validation to accept only HTTP(S)nexus.lucassantana.techorigins in link generationWEBAPP_BACKEND_URLandWEBAPP_REDIRECT_URIVerification
npm run test --workspace=packages/bot -- packages/bot/src/functions/general/commands/lastfm.spec.tsnpm run test --workspace=packages/bot -- lastfmnpm run type:check --workspace=packages/botSummary by CodeRabbit
Bug Fixes
Documentation