Skip to content

fix(badges): find tickets by number and enforce summit in badge endpoints - #681

Open
romanetar wants to merge 1 commit into
mainfrom
fix/badge-endpoints-ticket-number
Open

romanetar wants to merge 1 commit into
mainfrom
fix/badge-endpoints-ticket-number

Conversation

@romanetar

@romanetar romanetar commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

ref https://app.clickup.com/t/9014802374/1k5eh578rjz

Summary

Five badge endpoints under /api/v1/summits/{id}/tickets/{ticket_id}/badge are documented to take the ticket id or the ticket number (TICKET_...) in {ticket_id}. With the id they worked. With the number they always answered 404 Ticket not found, even when the ticket existed.

  • SummitOrderService::createBadge, deleteBadge, updateBadgeType, addAttendeeBadgeFeature and removeAttendeeBadgeFeature fell back to getByNumberExclusiveLock but dropped its result. The result is now assigned to $ticket.
  • createBadge and deleteBadge overwrote the $summit parameter with the summit of the order right before comparing them, so the check never failed and a badge could be created or deleted through the URL of another summit. They now compare against the summit of the URL and answer 404.
  • {ticket_id} is documented as "Ticket ID or number" (string) in the OpenAPI attributes of the five endpoints.

Tests

Eight new tests in tests/oauth2/OAuth2SummitTicketsApiTest.php:

  • one per endpoint called with the ticket number (5)
  • one calling all five with an unknown number, expecting 404
  • create badge and delete badge through the URL of another summit, expecting 404 and no change to the badge (2)

Against current main (tests only, without the fix) 7 of the 8 fail; the unknown-number test passes in both cases because it guards the existing 404. With the fix all pass.

vendor/bin/phpunit tests/oauth2/OAuth2SummitTicketsApiTest.php: OK (49 tests, 265 assertions), including testCreateAttendeeBadge, testDeleteAttendeeBadge, testUpdateAttendeeBadgeType, testAddAttendeeBadgeFeature and testRemoveAttendeeBadgeFeature, which call the endpoints with the ticket id.

php artisan l5-swagger:generate shows ticket_id as "Ticket ID or number", type string, on the five endpoints.

Risks

  • An endpoint that answered 404 for a ticket number now acts on the ticket. The lookup by number was already in the code of the five methods and is what the badge print endpoint does.
  • A client could rely on creating or deleting a badge through the URL of another summit. It was not checked which clients call these two endpoints. The other three badge endpoints already answered 404 in that case.
  • The id lookup runs first with intval(), so a ticket number starting with a digit would be taken for the id of another ticket. Numbers are generated with the TICKET_ prefix and none of the 88223 tickets in production starts with a digit (checked on 2026-11-19).

Out of scope

Notes

To run the test class locally it must run inside the summit-api container with REGISTRATION_VALIDATE_TICKET_TYPE_REMOVAL=false, as the CI does. Otherwise tearDown fails on every test of the class, also on main.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Badge creation, deletion, type updates, and feature changes can now identify tickets by ticket number as well as ticket ID.
  • Bug Fixes
    • Requests using unknown ticket numbers return a not-found response.
    • Badge creation and deletion requests using a different summit return a not-found response, without changing the ticket’s badge state.

…ints

The create, delete, update type, add feature and remove feature badge
endpoints are documented to take the ticket id or number in {ticket_id}.
SummitOrderService fell back to the lookup by number but dropped its
result, so a ticket found by number was treated as missing and the
endpoints always answered 404.

createBadge and deleteBadge also overwrote the summit received as
parameter with the summit of the order right before comparing them, so
a badge could be created or deleted through the URL of another summit.
Both now compare against the summit of the URL and answer 404.

Document {ticket_id} as ticket id or number (string) in the OpenAPI
attributes of the five endpoints and add tests for each endpoint called
with the ticket number, with an unknown number, and through another
summit.
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The five badge operations now accept ticket numbers when ticket ID lookup finds no ticket. The OpenAPI parameter descriptions and API tests reflect number-based requests, unknown ticket numbers, and cross-summit requests.

Changes: Ticket badge lookup by number

Layer / File(s) Summary
Document and implement ticket-number lookup
app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitTicketApiController.php, app/Services/Model/Imp/SummitOrderService.php
The five badge endpoint parameters are documented as accepting a ticket ID or number. The service falls back to ticket-number lookup when ID lookup finds no ticket.
Validate badge API behavior
tests/oauth2/OAuth2SummitTicketsApiTest.php
Tests cover number-based badge requests, unknown ticket numbers, and cross-summit creation and deletion requests.

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

Change: Bug fix

Possibly related PRs

  • OpenStackweb/summit-api#680: Updates refundTicket with a ticket summit membership check. Both PRs modify summit ownership checks for ticket operations in SummitOrderService.

Suggested reviewers: matiasperrone-exo, smarcet

Merge Risk: Minimal · up to 7ae05

The badge endpoints now accept ticket numbers as documented, and cross-summit requests are rejected with 404. No concrete merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(badges): find tickets by number and enforce summit in badge endpoints" matches the main change. The objectives and summary show the five badge endpoints now look up tickets by number, a…
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.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title "fix(badges): find tickets by number and enforce summit in badge endpoints" matches the main change. The objectives and summary show the five badge endpoints now look up tickets by number, and createBadge and deleteBadge now enforce the URL summit. The title names both changes, so it is fully related to the changeset.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: aaba842d-a339-4cc0-883a-449b12dcbbc4
Commits

Reviewing files that changed from the base of the PR and between d8c0633 and 7ae05d3.

Files selected for processing: 3

  • app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitTicketApiController.php
  • app/Services/Model/Imp/SummitOrderService.php
  • tests/oauth2/OAuth2SummitTicketsApiTest.php

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@github-actions

Copy link
Copy Markdown

📘 OpenAPI / Swagger preview

➡️ https://OpenStackweb.github.io/summit-api/openapi/pr-681/

This page is automatically updated on each push to this PR.

@romanetar romanetar self-assigned this Nov 19, 2026
@romanetar
romanetar requested a review from smarcet November 19, 2026 15:36

This branch has not been deployed

No deployments
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.

1 participant