Removing Default Referral Program Rule Set#1912
Conversation
🦋 Changeset detectedLatest commit: 5d6a405 The changes in this PR will be included in the next version bump. This PR includes changesets to release 24 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughRemoves hardcoded default referral program editions, renames the environment/config variable from Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant ENSApi
participant Config
participant Cache
participant ENSDb
rect rgba(200,230,255,0.5)
Client->>ENSApi: Request referral endpoint
ENSApi->>Config: Read referralProgramEditionConfigSetUrl (REFERRAL_PROGRAM_EDITIONS)
alt URL unset
Config-->>ENSApi: undefined
ENSApi->>Cache: buildReferralProgramEditionConfigSet([]) (early return)
Cache-->>ENSApi: empty edition set
ENSApi->>ENSDb: (skip referral-related queries)
ENSApi-->>Client: 404 / empty results for referral endpoints
else URL set
Config-->>ENSApi: URL
ENSApi->>Cache: fetch and parse edition set from URL
Cache->>ENSDb: query referral data (leaderboards/referrers)
ENSDb-->>Cache: referral data
Cache-->>ENSApi: edition set
ENSApi-->>Client: referral endpoint response
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
There was a problem hiding this comment.
Pull request overview
Removes the hardcoded “default” referral program edition rules/config from @namehash/ens-referrals and updates ENSApi to treat an unset referral editions URL env var as “no editions configured”, avoiding referral-related ENSDb work unless explicitly enabled.
Changes:
- Renamed
CUSTOM_REFERRAL_PROGRAM_EDITIONS→REFERRAL_PROGRAM_EDITIONSacross config typing, parsing, tests, and example env docs. - Removed the exported/default referral edition config set (and its implementation) from
@namehash/ens-referrals. - Updated validation to allow an empty editions array and adjusted tests accordingly.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/ensnode-sdk/src/shared/config/environments.ts | Renames/refines the referral editions env var contract. |
| packages/ens-referrals/src/v1/index.ts | Stops exporting the removed default editions helper. |
| packages/ens-referrals/src/v1/edition-defaults.ts | Deletes the hardcoded default edition definitions. |
| packages/ens-referrals/src/v1/api/zod-schemas.ts | Allows empty edition config arrays (no longer enforces non-empty). |
| packages/ens-referrals/src/v1/api/zod-schemas.test.ts | Updates tests to cover/accept empty arrays. |
| apps/ensapi/src/config/redact.ts | Renames redacted config field to the new URL property. |
| apps/ensapi/src/config/config.schema.ts | Renames schema/field and updates error message for new env var. |
| apps/ensapi/src/config/config.schema.test.ts | Updates tests for renamed env var and parsed config field. |
| apps/ensapi/src/cache/referral-program-edition-set.cache.ts | Removes default fallback; returns empty edition set when URL is unset; loads only from configured URL. |
| apps/ensapi/.env.local.example | Updates documentation to new env var name + “no editions configured” behavior. |
| .changeset/quiet-referrals-rest.md | Adds changeset documenting the removal + env var rename + empty-array allowance. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/ensapi/src/cache/referral-program-edition-set.cache.ts`:
- Around line 35-37: The log/error messages expose
config.referralProgramEditionConfigSetUrl.href verbatim; redact or sanitize the
URL before logging or rethrowing to avoid leaking credentials or signed query
params. Replace direct interpolation of
config.referralProgramEditionConfigSetUrl.href in logger.info and any error
throws with a sanitized value (e.g., strip username/password and query string or
replace with a placeholder) by adding a small helper (sanitizeUrl or redactUrl)
and using that helper wherever config.referralProgramEditionConfigSetUrl.href is
logged or included in thrown errors.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: db31802e-8989-48a0-95cc-566a5943ec1a
📒 Files selected for processing (11)
.changeset/quiet-referrals-rest.mdapps/ensapi/.env.local.exampleapps/ensapi/src/cache/referral-program-edition-set.cache.tsapps/ensapi/src/config/config.schema.test.tsapps/ensapi/src/config/config.schema.tsapps/ensapi/src/config/redact.tspackages/ens-referrals/src/v1/api/zod-schemas.test.tspackages/ens-referrals/src/v1/api/zod-schemas.tspackages/ens-referrals/src/v1/edition-defaults.tspackages/ens-referrals/src/v1/index.tspackages/ensnode-sdk/src/shared/config/environments.ts
💤 Files with no reviewable changes (2)
- packages/ens-referrals/src/v1/index.ts
- packages/ens-referrals/src/v1/edition-defaults.ts
…rral-program-rule-set
Greptile SummaryThis PR removes the hardcoded default referral program edition config set ( The changes are consistent across all layers — config schema, cache loader, Zod validation, env-var type definitions, redaction, and documentation. Confidence Score: 5/5Safe to merge — clean, consistent removal of hardcoded defaults with no regressions introduced. All changes are self-consistent: the env var rename flows through every layer (SDK interface, config schema, cache loader, redaction, docs, tests), the empty-array case is explicitly tested in the Zod schema suite, and the No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[SWRCache initializes\nproactivelyInitialize: true] --> B{REFERRAL_PROGRAM_EDITIONS\nenv var set?}
B -- No --> C[Log info: zero editions]
C --> D[Return empty\nReferralProgramEditionConfigSet]
B -- Yes --> E[Fetch JSON from URL\nvia ENSReferralsClient]
E -- Error --> F[Throw error\ncached for errorTtl=1min]
E -- Success --> G[Iterate editions]
G --> H{awardModel\nrecognized?}
H -- No --> I[Log warn, delete\nfrom config set]
H -- Yes --> J[Keep edition]
I --> K[Return filtered\nReferralProgramEditionConfigSet]
J --> K
D --> L[Cache forever\nttl=Infinity]
K --> L
Reviews (1): Last reviewed commit: "Merge remote-tracking branch 'origin' in..." | Re-trigger Greptile |
There was a problem hiding this comment.
Pull request overview
This PR removes the hardcoded “default” referral program editions configuration and shifts ENSApi to treating an unset referral editions config URL as “no editions configured,” avoiding referral-related ENSDb work unless explicitly enabled.
Changes:
- Removed the default editions implementation/export (
edition-defaults.ts) from@namehash/ens-referrals. - Renamed the environment variable from
CUSTOM_REFERRAL_PROGRAM_EDITIONStoREFERRAL_PROGRAM_EDITIONS(and corresponding config fields in ENSApi). - Updated validation to allow an empty editions array and refreshed
.env.local.example+ changeset.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/ensnode-sdk/src/shared/config/environments.ts | Renames/refines the referral editions env var contract. |
| packages/ens-referrals/src/v1/index.ts | Stops exporting removed default-editions module. |
| packages/ens-referrals/src/v1/edition-defaults.ts | Deletes hardcoded default referral editions config. |
| packages/ens-referrals/src/v1/api/zod-schemas.ts | Allows an empty referral editions array by removing the non-empty constraint. |
| packages/ens-referrals/src/v1/api/zod-schemas.test.ts | Updates schema tests to cover empty array acceptance. |
| apps/ensapi/src/config/redact.ts | Redacts the configured referral editions URL when logging config. |
| apps/ensapi/src/config/config.schema.ts | Renames the config field and updates the env var name in validation/errors. |
| apps/ensapi/src/config/config.schema.test.ts | Updates tests for the renamed env var/config field. |
| apps/ensapi/src/cache/referral-program-edition-set.cache.ts | Loads editions only from configured URL; otherwise caches an empty set. |
| apps/ensapi/.env.local.example | Updates documentation and env var name for referral editions config. |
| .changeset/quiet-referrals-rest.md | Declares release notes/version bumps for the breaking-ish change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lightwalker-eth
left a comment
There was a problem hiding this comment.
@Goader Looks good 👍 Shared very small suggestions please take the lead to merge when ready
| * Returns `origin + pathname`, stripping any credentials or query params | ||
| * so the URL is safe to include in log messages and error strings. | ||
| */ | ||
| function safeHref(url: URL): string { |
There was a problem hiding this comment.
| function safeHref(url: URL): string { | |
| function partiallyRedactUrl(url: URL): string { |
Wdyt?
| /** | ||
| * Loads the referral program edition config set from custom URL or defaults. | ||
| * Returns `origin + pathname`, stripping any credentials or query params | ||
| * so the URL is safe to include in log messages and error strings. |
There was a problem hiding this comment.
| * so the URL is safe to include in log messages and error strings. | |
| * so the URL is theoretically safer to include in log messages and error strings. |
There was a problem hiding this comment.
Pull request overview
This PR removes the hardcoded “default” referral program edition ruleset and updates ENSApi to treat an unset referral editions env var as “no editions configured,” avoiding referral-related ENSDb work unless explicitly enabled.
Changes:
- Removed the default referral editions config implementation/export and updated ENSApi to return an empty edition set when no URL is configured.
- Renamed
CUSTOM_REFERRAL_PROGRAM_EDITIONS→REFERRAL_PROGRAM_EDITIONSacross config/env parsing and examples. - Relaxed the referrals editions config schema to allow an empty editions array (and updated tests + changeset).
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/ensnode-sdk/src/shared/config/environments.ts | Renames the referral editions env var type and clarifies “unset means no editions / no ENSDb work”. |
| packages/ens-referrals/src/v1/index.ts | Stops exporting the removed default editions module. |
| packages/ens-referrals/src/v1/edition-defaults.ts | Removes the hardcoded default referral editions ruleset. |
| packages/ens-referrals/src/v1/api/zod-schemas.ts | Allows an empty referral editions array (removes non-empty constraint). |
| packages/ens-referrals/src/v1/api/zod-schemas.test.ts | Updates tests to assert empty-array acceptance and keeps malformed-input coverage. |
| apps/ensapi/src/config/redact.ts | Redacts the configured referral editions URL (if present) and updates the config key name. |
| apps/ensapi/src/config/config.schema.ts | Renames the env var + config field and updates validation error messaging. |
| apps/ensapi/src/config/config.schema.test.ts | Updates config parsing tests for the renamed env var and config field. |
| apps/ensapi/src/cache/referral-program-edition-set.cache.ts | Removes default-loading path; returns an empty set when unconfigured and avoids logging sensitive URL parts. |
| apps/ensapi/.env.local.example | Updates env documentation to the new variable name and new “unset => empty editions” behavior. |
| .changeset/quiet-referrals-rest.md | Declares version bumps and documents the behavioral/config changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Remove "default" referral program rule set
closes: #1905
Summary
edition-defaults.ts)CUSTOM_REFERRAL_PROGRAM_EDITIONS→REFERRAL_PROGRAM_EDITIONS.env.local.exampleWhy
Testing
Notes for Reviewer (Optional)
initializeReferralLeaderboardEditionsCachesproduces an empty cache map, leaderboard/referrer endpoints return 404 for any edition, and/editionsreturns an empty listPre-Review Checklist (Blocking)