Skip to content

Conversation

@devksingh4
Copy link
Member

@devksingh4 devksingh4 commented Nov 11, 2025

Summary by CodeRabbit

Release Notes

  • Chores

    • Updated domain configuration for URL redirect routing
    • Refined slug mapping logic to handle single-part hostnames
  • Tests

    • Added comprehensive test coverage for redirect functionality, including edge cases, fallback behavior, path handling, and cache control validation

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 11, 2025

Walkthrough

Updates domain configuration in the linkry edge function by replacing domains with new prefixed variants and narrows slug-to-query mapping logic to single-part hostnames only. Adds comprehensive unit tests for CloudFront Lambda@Edge handler covering redirects, cache control, organization shortcodes, and error scenarios.

Changes

Cohort / File(s) Summary
Domain Configuration Update
src/linkryEdgeFunction/index.ts
Updated BASE_DOMAINS array by replacing .acm.illinois.edu, .aws.qa.acmuiuc.org with .go.acm.illinois.edu, .go.aws.qa.acmuiuc.org; retained .acm.gg. Modified getSlugToQuery condition from hostParts.length > 1 to hostParts.length === 1, restricting slug-to-query mapping to single-part hostnames only.
Test Suite Addition
tests/unit/linkryEdgeFunction/main.test.ts
Added comprehensive unit test suite for CloudFront Lambda@Edge handler using aws-sdk-client-mock to mock DynamoDB. Tests cover empty path redirects, successful redirects with cache headers, organization shortcode handling, DynamoDB query fallback behavior, path handling with special characters, edge cases (missing headers, non-Error exceptions), query parameter/fragment preservation, and Cache-Control header validation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • The domain array replacement is straightforward, but verify the .go prefix addition aligns with infrastructure intentions
  • The condition inversion (hostParts.length > 1hostParts.length === 1) warrants validation of its impact on hostname resolution for all configured domains
  • Test file follows standard mocking patterns; scan for completeness of DynamoDB query parameter assertions and edge case coverage

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Edge redirect function enhancements' is directly related to the main changes in the pull request, which update the BASE_DOMAINS array, modify slug-to-query logic in the edge function, and add comprehensive unit tests for the CloudFront Lambda@Edge handler.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dsingh14/edge-function

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Contributor

💰 Infracost report

Monthly estimate generated

This comment will be updated when code changes.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/unit/linkryEdgeFunction/main.test.ts (1)

1-476: Excellent test coverage!

The test suite is comprehensive and well-structured, covering:

  • Empty path handling with proper redirects
  • Successful DynamoDB lookups with correct query parameters
  • Organization shortcode logic for all domain variants
  • Fallback scenarios (missing items, errors, malformed data)
  • Path normalization and edge cases
  • Cache control headers across all response types

The tests properly validate the new domain structure (.go.acm.illinois.edu, .go.aws.qa.acmuiuc.org, .acm.gg) and the updated slug-to-query mapping logic.

Minor formatting issues flagged by ESLint can be addressed:

-  };
+  }

The import extension issue (line 8) may need to be resolved based on your project's TypeScript/ESLint configuration, though it's typically a configuration matter rather than a code issue.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between c5760df and 9cb1170.

📒 Files selected for processing (2)
  • src/linkryEdgeFunction/index.ts (2 hunks)
  • tests/unit/linkryEdgeFunction/main.test.ts (1 hunks)
🧰 Additional context used
🪛 ESLint
tests/unit/linkryEdgeFunction/main.test.ts

[error] 1-1: Resolve error: EACCES: permission denied, open '/NxCZHueWoq'
at Object.writeFileSync (node:fs:2409:20)
at l (/home/jailuser/git/node_modules/get-tsconfig/dist/index.cjs:7:13685)
at createFilesMatcher (/home/jailuser/git/node_modules/get-tsconfig/dist/index.cjs:7:14437)
at Object.resolve (/home/jailuser/git/node_modules/eslint-import-resolver-typescript/lib/index.cjs:298:107)
at withResolver (/home/jailuser/git/node_modules/eslint-module-utils/resolve.js:180:23)
at fullResolve (/home/jailuser/git/node_modules/eslint-module-utils/resolve.js:201:22)
at relative (/home/jailuser/git/node_modules/eslint-module-utils/resolve.js:217:10)
at resolve (/home/jailuser/git/node_modules/eslint-module-utils/resolve.js:233:12)
at checkFileExtension (/home/jailuser/git/node_modules/eslint-plugin-import/lib/rules/extensions.js:205:53)
at checkSourceValue (/home/jailuser/git/node_modules/eslint-module-utils/moduleVisitor.js:32:5)

(import/extensions)


[error] 8-8: Unexpected use of file extension "js" for "../../../src/linkryEdgeFunction/index.js"

(import/extensions)


[error] 52-52: Delete ;

(prettier/prettier)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Run Unit Tests
  • GitHub Check: Build Application
🔇 Additional comments (1)
src/linkryEdgeFunction/index.ts (1)

18-22: No critical code issues found; review comment concern is about external runtime impact, not codebase stability.

The BASE_DOMAINS change in src/linkryEdgeFunction/index.ts is scoped exclusively to the linkry short link service and does not affect other domain references in the codebase (core.acm.illinois.edu, static.acm.illinois.edu, etc.). The existing codebase already uses the .go. prefix pattern for short links throughout tests and configuration files, indicating this change aligns with the current architecture.

Any breaking impact would be limited to externally-issued short links using the old domain pattern—not codebase dependencies.

@devksingh4 devksingh4 merged commit 26bcec3 into main Nov 11, 2025
12 of 13 checks passed
@devksingh4 devksingh4 deleted the dsingh14/edge-function branch November 11, 2025 22:55
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.

2 participants