Skip to content

Fix silent data loss when platform defaults to reddit for Twitter-only simulations#151

Open
karesansui-u wants to merge 1 commit into666ghj:mainfrom
karesansui-u:fix/platform-default-reddit-silent-failure
Open

Fix silent data loss when platform defaults to reddit for Twitter-only simulations#151
karesansui-u wants to merge 1 commit into666ghj:mainfrom
karesansui-u:fix/platform-default-reddit-silent-failure

Conversation

@karesansui-u
Copy link

Summary

  • API retrieval endpoints (/profiles, /profiles/realtime, /posts, /comments) hardcoded 'reddit' as the default platform
  • When a Twitter-only simulation was run (enable_reddit=false), these APIs silently returned empty results because they looked for reddit_simulation.db / reddit_profiles.json which did not exist
  • Frontend also hardcoded 'reddit' in Vue components and API wrapper functions

Changes

Backend (simulation.py, simulation_manager.py):

  • Add SimulationState.get_default_platform() that reads enable_twitter/enable_reddit config
  • Add _get_default_platform() helper in the API layer (follows existing _check_simulation_prepared pattern)
  • Replace hardcoded 'reddit' defaults in 4 endpoints with config-aware defaults
  • Add platform parameter to /comments endpoint (was hardcoded to reddit_simulation.db)

Frontend (simulation.js, Step2EnvSetup.vue, Step5Interaction.vue):

  • Remove hardcoded 'reddit' defaults from 3 API functions; omit platform param to let backend decide
  • Remove hardcoded 'reddit' from 2 Vue component calls

Scope: This PR fixes the API retrieval layer only. The profile generation layer (oasis_profile_generator.py) already correctly selects platform based on simulation config.

Backward compatible: Explicit platform=reddit or platform=twitter still works as before.

Test plan

  • Create a Twitter-only simulation (enable_reddit=false) and verify profiles/posts/comments are returned
  • Create a Reddit-only simulation and verify existing behavior is unchanged
  • Create a parallel (both platforms) simulation and verify default falls back to reddit

Fixes #150

…y simulations

The API retrieval layer hardcoded reddit as the default platform in 11+ locations. When a Twitter-only simulation was run, all data retrieval APIs silently returned empty results because they looked for reddit_simulation.db which did not exist. This commit reads the simulation enable_twitter/enable_reddit config to determine the correct default platform.

Fixes 666ghj#150
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Hardcoded 'reddit' platform default causes silent data loss for Twitter-only simulations

1 participant