Skip to content

fix(geo-data): correct country_id mismatch in states.csv and cities.csv#1682

Open
YogeshK34 wants to merge 1 commit into
credebl:mainfrom
YogeshK34:fix/geo-data-clean
Open

fix(geo-data): correct country_id mismatch in states.csv and cities.csv#1682
YogeshK34 wants to merge 1 commit into
credebl:mainfrom
YogeshK34:fix/geo-data-clean

Conversation

@YogeshK34

Copy link
Copy Markdown

Problem

states.csv contains a systematic country_id corruption affecting all countries from Germany onward (~148 countries). The country_code column is correct, but country_id values don't match the IDs in countries.csv — causing states of one country to be served under another.

Example:

File name country_id (before) country_code Actual country
states.csv Andhra Pradesh 99 IN Hong Kong (99) ≠ India (102)

This means selecting India in the UI returned Iran's states. Selecting Hong Kong returned India's states. No error is thrown — the data is silently wrong.

cities.csv had the same downstream corruption.

Root Cause

The country_id column was not derived from countries.csv IDs. The country_code column was always correct, but country_id diverged for ~148 countries starting alphabetically around Germany.

Fix

Regenerated country_id in both CSVs by mapping country_code (ISO) → correct id from countries.csv.

  • states.csv — 4,581 rows corrected
  • cities.csv — 105,446 rows corrected

Impact

Scenario Impact
Fresh local setup / CI ✅ Fixed — correct geo data on first seed
Existing seeded deployment ✅ No impact — import script skips non-empty tables

Testing

-- Verify India's states return correctly
SELECT * FROM states WHERE country_id = 102 LIMIT 5;
-- All rows should have country_code = 'IN'

Note

Supersedes #1681 — this PR isolates only the geo-data fix.

Signed-off-by: yogeshk34 <khutwadyogesh34@gmail.com>
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@YogeshK34, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 50 minutes and 4 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 359e41a1-a186-4fa8-804f-cdea2e17507d

📥 Commits

Reviewing files that changed from the base of the PR and between 8380043 and 95f2de6.

⛔ Files ignored due to path filters (2)
  • libs/prisma-service/prisma/data/geo-location-master-data/cities.csv is excluded by !**/*.csv
  • libs/prisma-service/prisma/data/geo-location-master-data/states.csv is excluded by !**/*.csv
📒 Files selected for processing (1)
  • libs/prisma-service/prisma/seed.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@sonarqubecloud

Copy link
Copy Markdown

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.

1 participant