Skip to content

Vote schema has empty changeset with no validation/required fields. #2557

@khushal-winner

Description

@khushal-winner
  • Describe the bug
    The Vote schema defines a changeset/2 function that casts no fields and validates nothing (cast(attrs, []) + validate_required([])), providing zero input validation. However, the app never uses this changeset votes are inserted directly via %Vote{…} |> Repo.insert().

  • Expected behavior
    Schema changesets should enforce required fields and proper casting/validation (e.g. cast(attrs, [:dealt_card_id, :player_id]) + validate_required([:dealt_card_id, :player_id])) to prevent invalid data, follow Ecto best practices, and protect against future misuse.

  • Desktop (please complete the following information):
    OS: N/A (server-side schema / code quality issue)
    Browser: N/A (server-side schema / code quality issue)
    Version: N/A (server-side schema / code quality issue)

  • Additional context
    Not currently exploitable DB foreign-key constraints + direct struct insertion prevent bad data today. Still poor practice / technical debt: empty changeset violates Ecto conventions and creates risk if anyone later starts using Vote.changeset/2 (e.g. API, admin form, bulk insert). Fix recommended for maintainability and defense-in-depth.

Metadata

Metadata

Assignees

No one assigned

    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