Skip to content

Commit ae261a7

Browse files
caseylockerclaude
andcommitted
fix(promo-codes): address CodeRabbit findings — CSV domain import and migration rollback
CodeRabbit flagged 6 issues on PR #525. After independent validation (Codex), 2 were confirmed as real bugs, 2 were false positives, and 2 were informational/misframed. Fixed (validated as real): - **CSV import TypeError:** `allowed_email_domains` was not exploded from its pipe-delimited CSV string before reaching `setAllowedEmailDomains(array)`, causing a TypeError on domain-authorized code import. Added the same `explode('|', ...)` normalization used by all other CSV list fields in both the add and update import paths. - **Migration down() failure:** Dropping the joined domain-authorized tables did not remove orphaned base-table rows, so narrowing the ClassName ENUM would fail if any domain-authorized promo codes existed. Added a DELETE statement before the ALTER TABLE. Dismissed (validated as false positives): - `remaining_quantity_per_account = null` in MemberDiscountCode serializer is correct — Member types do not have per-account quantity. - Discover route already has OAuth2 auth via the `api` middleware group and an explicit controller-level null-member guard. Adding `auth.user` would break it (requires authz_groups, intentionally removed in 138c1f8). Deferred: - `boolval("false")` pattern is pre-existing across the factory (not introduced by this PR); warrants a separate cleanup. - Multi-level TLD validation regex (`.co.uk`) is an enhancement, not a bug in the current domain-matching logic. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 19e5f53 commit ae261a7

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

app/Services/Model/Imp/SummitPromoCodeService.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,10 @@ public function importPromoCodes(Summit $summit, UploadedFile $csv_file, ?Member
642642
$row['tags'] = explode('|', $row['tags']);
643643
}
644644

645+
if(isset($row['allowed_email_domains'])){
646+
$row['allowed_email_domains'] = explode('|', $row['allowed_email_domains']);
647+
}
648+
645649
if(isset($row['ticket_types_rules']) && (isset($row['amount']) || isset($row['rate']))){
646650

647651
$row['ticket_types_rules'] = explode('|', $row['ticket_types_rules']);
@@ -745,6 +749,10 @@ public function importSponsorPromoCodes(Summit $summit, UploadedFile $csv_file,
745749
$row['tags'] = explode('|', $row['tags']);
746750
}
747751

752+
if(isset($row['allowed_email_domains'])){
753+
$row['allowed_email_domains'] = explode('|', $row['allowed_email_domains']);
754+
}
755+
748756
if(isset($row['ticket_types_rules']) && (isset($row['amount']) || isset($row['rate']))){
749757

750758
$row['ticket_types_rules'] = explode('|', $row['ticket_types_rules']);

database/migrations/model/Version20260401150000.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ public function down(Schema $schema): void
100100
$this->addSql("DROP TABLE IF EXISTS DomainAuthorizedSummitRegistrationPromoCode");
101101
$this->addSql("DROP TABLE IF EXISTS DomainAuthorizedSummitRegistrationDiscountCode");
102102

103+
// 4b. Delete orphaned base-table rows before narrowing the ENUM
104+
$this->addSql("DELETE FROM SummitRegistrationPromoCode WHERE ClassName IN (
105+
'DomainAuthorizedSummitRegistrationDiscountCode',
106+
'DomainAuthorizedSummitRegistrationPromoCode'
107+
)");
108+
103109
// 5. Revert the ClassName discriminator ENUM to the original 12 values
104110
$this->addSql("ALTER TABLE SummitRegistrationPromoCode MODIFY ClassName ENUM(
105111
'SummitRegistrationPromoCode',

0 commit comments

Comments
 (0)