Skip to content

fix(platforms): stop platform variants from renaming the parent platform#3693

Merged
gantoine merged 1 commit into
masterfrom
posthog-code/fix-platform-variant-rename
Jul 6, 2026
Merged

fix(platforms): stop platform variants from renaming the parent platform#3693
gantoine merged 1 commit into
masterfrom
posthog-code/fix-platform-variant-rename

Conversation

@gantoine

@gantoine gantoine commented Jul 6, 2026

Copy link
Copy Markdown
Member

Description
Explain the changes or enhancements you are proposing with this pull request.

When a folder is mapped as a Platform Variant (or Folder Alias) of an existing platform, the scanner resolves that folder to the parent's slug. The database then holds two platform rows sharing the same slug (e.g. the real arcade folder and an fbneo folder both with slug="arcade").

get_supported_platforms() built its slug→platform map with a plain dict comprehension:

db_platforms_map = {p.slug: p for p in db_platforms}

With two rows sharing a slug, whichever came last (platforms are ordered by name) silently overwrote the parent, so the platform picker and Folder Mappings page displayed the variant's name instead of the parent's. This is what caused Arcade to be "renamed" to FBneo, and the reported WiiWare/WiiVC case.

The fix prefers the canonical platform (the one whose fs_slug matches its slug) when building the map, so a variant/alias folder can no longer shadow its parent.

Note: variants remain their own platform row borrowing the parent's metadata, which is the documented intent of "Platform variant". This PR only fixes the naming collision.

Fixes #3157

Checklist
Please check all that apply.

  • I've tested the changes locally
  • I've updated relevant comments
  • I've assigned reviewers for this PR
  • I've added unit tests that cover the changes

Screenshots (if applicable)

N/A (backend-only change)


AI assistance disclosure

This change was written with AI assistance (PostHog Code). The AI performed the investigation, implemented the fix, and wrote the accompanying test; the change has been reviewed before submission.


Created with PostHog Code

get_supported_platforms built a slug->platform map with a plain dict
comprehension. When a folder is mapped as a variant or alias of an
existing platform, scanning resolves it to the parent slug, so two
platform rows share the same slug. The comprehension let the later row
(the variant) overwrite the parent, renaming it in the platform picker
and Folder Mappings page.

Prefer the canonical platform (fs_slug == slug) when building the map so
a variant folder no longer shadows its parent.

Fixes #3157

Generated-By: PostHog Code
Task-Id: 571866ea-86a0-49c2-b62e-dbea077d0181
Copilot AI review requested due to automatic review settings July 6, 2026 14:17

Copilot AI 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.

Pull request overview

Fixes a backend bug where platform variant / folder alias rows that share the parent platform’s slug could silently overwrite the canonical platform entry in get_supported_platforms(), causing the UI to display the variant’s name (e.g., “FBneo”) instead of the parent (“Arcade”).

Changes:

  • Update get_supported_platforms() to prefer the canonical platform row (fs_slug == slug) when multiple DB rows share the same slug.
  • Add a regression test ensuring a variant row cannot shadow the parent platform’s display name.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
backend/utils/platforms.py Builds the slug→platform map in a way that prevents variant/alias rows from overwriting the canonical platform entry.
backend/tests/utils/test_platforms.py Regression test covering the “variant shadows parent” slug-collision case.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gantoine
gantoine merged commit 64ab9c6 into master Jul 6, 2026
11 checks passed
@gantoine
gantoine deleted the posthog-code/fix-platform-variant-rename branch July 6, 2026 15:34
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.

[Bug] Arcade platform gets renamed to FBneo after I add FBNeo folder and assign platform as Arcade

2 participants