Skip to content

Bug: {:ok, redirect()} used instead of {:noreply, redirect()} in PlayerLive.Show causing HTTP 500 on invalid player ID #2505

@Adarshkumar0509

Description

@Adarshkumar0509

Describe the bug
While reading through the codebase I noticed that player_live/show.ex has three places where error redirects return {:ok, redirect(socket, to: "/error")} instead of the correct {:noreply, redirect(socket, to: "/error")}. In Phoenix LiveView, callbacks like handle_params and handle_info must always return {:noreply, socket} — returning {:ok, socket} is incorrect and will cause the redirect to not work as expected when a player or game is not found.

To Reproduce
Steps to reproduce the behavior:

  1. Visit https://copi.owasp.org/games/new and create a game
  2. Copy the game ID from the URL
  3. Visit /games/:game_id/players/invalid-id directly
  4. See HTTP 500 instead of proper error redirect

Screenshots
Image

Expected behavior
The error redirects should return {:noreply, redirect(socket, to: "/error")} just like game_live/show.ex already does correctly.

Desktop (please complete the following information):

  • OS: windows 11
  • Browser: chrome
  • Version: N/A

Additional context
The bug exists in 3 places in lib/copi_web/live/player_live/show.ex:

  1. handle_params when player is not found
  2. handle_params when game is not found
  3. handle_info when player is not found after game update

Are you going to work on fixing this?

  • Yes
  • No

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions