Skip to content

Fix MapConsistency test: normalize custom_tribes key order to match gen-maps output 🧪 - #4809

Merged
ryanbarlow97 merged 2 commits into
mainfrom
fix-map-consistency-key-order
Jul 31, 2026
Merged

Fix MapConsistency test: normalize custom_tribes key order to match gen-maps output 🧪#4809
ryanbarlow97 merged 2 commits into
mainfrom
fix-map-consistency-key-order

Conversation

@FloPinguin

Copy link
Copy Markdown
Contributor

Description:

The info.json metadata matches the generated Maps.gen.ts test in MapConsistency was comparing custom_tribes via JSON.stringify, which is key-order-sensitive. Info.json files store tribes as {"coordinates":[...],"name":"..."} while the gen-maps codegen always outputs {name: "...", coordinates: [...]} (name first). The normalizeCustomTribes function passed through raw objects without reordering keys, causing semantically identical data to fail the string comparison.

This fix explicitly reconstructs custom tribe objects in normalizeCustomTribes with consistent key ordering (name first, then coordinates) to match the gen-maps output format.

Please complete the following:

  • I have added screenshots for all UI updates
  • I process any text displayed to the user through translateText() and I've added it to the en.json file
  • I have added relevant tests to the test directory

Please put your Discord username so you can be contacted if a bug or regression is found:

FloPinguin

@FloPinguin FloPinguin added this to the v33 milestone Jul 31, 2026
@FloPinguin
FloPinguin requested a review from a team as a code owner July 31, 2026 09:05
@FloPinguin FloPinguin added the Maps A new map, or adjustments to an existing map itself, its json, etc, label Jul 31, 2026
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 12b64f94-f6fc-4e2c-acb8-68c60c804ebc

📥 Commits

Reviewing files that changed from the base of the PR and between 4f26ee8 and 30e94c2.

📒 Files selected for processing (1)
  • tests/MapConsistency.test.ts

Walkthrough

normalizeCustomTribes now validates every custom-tribe entry. Valid strings and objects become consistent objects. Invalid values, names, and coordinates throw indexed errors.

Changes

Custom tribe normalization

Layer / File(s) Summary
Validate and normalize custom tribe entries
tests/MapConsistency.test.ts
Empty strings, invalid values, missing or empty names, and malformed coordinates now throw indexed errors. Valid entries retain their name and optional numeric coordinates.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: evanpelle

Poem

Custom tribes face the test,
Valid shapes pass cleanly best.
Names stay clear, coordinates align,
Bad entries stop at the indexed line.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the MapConsistency test fix and the custom_tribes key-order normalization.
Description check ✅ Passed The description accurately explains the key-order fix and the added runtime validation for normalizeCustomTribes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/MapConsistency.test.ts`:
- Around line 76-80: The helper that reconstructs custom tribe entries must
validate each entry before accessing properties. Add a runtime guard ensuring
the entry is a non-null object with a valid string name and, when present, valid
coordinates; reject invalid entries by throwing or returning an error, while
preserving the existing name-first reconstruction for valid entries.
🪄 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: CHILL

Plan: Pro Plus

Run ID: 618e6ae9-2891-44ad-8a2e-180e83d3b2af

📥 Commits

Reviewing files that changed from the base of the PR and between 2f48ae9 and 4f26ee8.

📒 Files selected for processing (1)
  • tests/MapConsistency.test.ts

Comment thread tests/MapConsistency.test.ts Outdated
@github-project-automation github-project-automation Bot moved this from Triage to Development in OpenFront Release Management Jul 31, 2026

@ryanbarlow97 ryanbarlow97 left a comment

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.

thanks

@github-project-automation github-project-automation Bot moved this from Development to Final Review in OpenFront Release Management Jul 31, 2026
@ryanbarlow97
ryanbarlow97 added this pull request to the merge queue Jul 31, 2026
Merged via the queue into main with commit 9e53846 Jul 31, 2026
14 checks passed
@ryanbarlow97
ryanbarlow97 deleted the fix-map-consistency-key-order branch July 31, 2026 10:38
@github-project-automation github-project-automation Bot moved this from Final Review to Complete in OpenFront Release Management Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Maps A new map, or adjustments to an existing map itself, its json, etc,

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

2 participants