fix(audit): allow nullable sponsor in SummitSponsorExtraQuestionType::getSponsor#531
Conversation
…:getSponsor Signed-off-by: romanetar <roman_ag@hotmail.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughNullable sponsor relationships were formalized across models, serializers, events, and email/job logic: method signatures and PHPDoc now allow Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/summit-api/openapi/pr-531/ This page is automatically updated on each push to this PR. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
app/Models/Foundation/Summit/ExtraQuestions/SummitSponsorExtraQuestionType.php (1)
45-47: Make nullability annotations consistent across the model.Lines 45/47 are nullable, but the property docblock at Line 38 still states
@var Sponsoreven thoughclearSponsor()sets it to null. Update it toSponsor|nullto keep static-analysis metadata aligned.Suggested diff
- /** - * `@var` Sponsor - */ + /** + * `@var` Sponsor|null + */🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/Models/Foundation/Summit/ExtraQuestions/SummitSponsorExtraQuestionType.php` around lines 45 - 47, Update the docblock for the sponsor property in SummitSponsorExtraQuestionType to match the nullable return/type usage: change the property annotation from `@var` Sponsor to `@var` Sponsor|null so it aligns with getSponsor(): ?Sponsor and clearSponsor() which sets the property to null; locate the property docblock above the class field (currently annotated as Sponsor) and make it Sponsor|null to keep static-analysis and IDE hints consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@app/Models/Foundation/Summit/ExtraQuestions/SummitSponsorExtraQuestionType.php`:
- Around line 45-47: The property docblock for the sponsor field is inaccurate:
update the `@var` annotation (currently `@var` Sponsor) to `@var` Sponsor|null to
match the nullable return type of getSponsor(): ?Sponsor and the behavior of
clearSponsor() which can set the property to null; locate the property
declaration (the $sponsor property) in SummitSponsorExtraQuestionType and change
its docblock to include "|null".
---
Nitpick comments:
In
`@app/Models/Foundation/Summit/ExtraQuestions/SummitSponsorExtraQuestionType.php`:
- Around line 45-47: Update the docblock for the sponsor property in
SummitSponsorExtraQuestionType to match the nullable return/type usage: change
the property annotation from `@var` Sponsor to `@var` Sponsor|null so it aligns with
getSponsor(): ?Sponsor and clearSponsor() which sets the property to null;
locate the property docblock above the class field (currently annotated as
Sponsor) and make it Sponsor|null to keep static-analysis and IDE hints
consistent.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b02f750b-aba1-4599-88f3-de2a79ce0eda
📒 Files selected for processing (1)
app/Models/Foundation/Summit/ExtraQuestions/SummitSponsorExtraQuestionType.php
Signed-off-by: romanetar <roman_ag@hotmail.com>
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/summit-api/openapi/pr-531/ This page is automatically updated on each push to this PR. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
app/Models/Foundation/Summit/Registration/PromoCodes/Traits/SponsorPromoCodeTrait.php (1)
74-77: Keep property PHPDoc consistent with nullable getter.
getSponsor()is now nullable, but the trait property doc still states non-nullSponsor. Aligning both avoids static-analysis drift.Suggested doc consistency patch
- /** - * `@var` Sponsor - */ + /** + * `@var` Sponsor|null + */ #[ORM\JoinColumn(name: 'SponsorID', referencedColumnName: 'ID')] #[ORM\ManyToOne(targetEntity: \models\summit\Sponsor::class)] protected $sponsor;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/Models/Foundation/Summit/Registration/PromoCodes/Traits/SponsorPromoCodeTrait.php` around lines 74 - 77, Update the PHPDoc for the trait property that backs getSponsor() to match the nullable return type; change the property's doc from Sponsor to Sponsor|null so it aligns with the nullable getter getSponsor(): ?Sponsor in SponsorPromoCodeTrait and avoids static-analysis warnings.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/Models/Foundation/Summit/SponsorStatistics.php`:
- Around line 69-72: The serializers dereference
$code->getSponsor()->getCompany()->getName() without guarding for a null
sponsor; update SponsorSummitRegistrationDiscountCodeSerializer and
SponsorSummitRegistrationPromoCodeSerializer to check $code->hasSponsor() (or
$code->getSponsor() !== null) before calling getCompany()/getName(), mirroring
the pattern used in SponsorBadgeScanSerializer::hasSponsor(); if no sponsor,
return a safe fallback (e.g., null or empty string) or handle it explicitly in
the serialized output so the code never calls getCompany() on a null Sponsor.
---
Nitpick comments:
In
`@app/Models/Foundation/Summit/Registration/PromoCodes/Traits/SponsorPromoCodeTrait.php`:
- Around line 74-77: Update the PHPDoc for the trait property that backs
getSponsor() to match the nullable return type; change the property's doc from
Sponsor to Sponsor|null so it aligns with the nullable getter getSponsor():
?Sponsor in SponsorPromoCodeTrait and avoids static-analysis warnings.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 39c26aa1-8d25-47da-88af-3fcaada9b284
📒 Files selected for processing (14)
app/Events/SponsorServices/SummitSponsorshipAddOnCreatedEventDTO.phpapp/Events/SponsorServices/SummitSponsorshipCreatedEventDTO.phpapp/Jobs/Emails/Registration/PromoCodes/SponsorPromoCodeEmail.phpapp/ModelSerializers/Summit/Registration/PromoCodes/SponsorSummitRegistrationDiscountCodeSerializer.phpapp/ModelSerializers/Summit/Registration/PromoCodes/SponsorSummitRegistrationPromoCodeSerializer.phpapp/ModelSerializers/Summit/Registration/SponsorBadgeScanCSVSerializer.phpapp/ModelSerializers/Summit/Registration/SponsorUserInfoGrantCSVSerializer.phpapp/Models/Foundation/Summit/ExtraQuestions/SummitSponsorExtraQuestionType.phpapp/Models/Foundation/Summit/Registration/PromoCodes/Traits/SponsorPromoCodeTrait.phpapp/Models/Foundation/Summit/Registration/SponsorUserInfoGrant.phpapp/Models/Foundation/Summit/SponsorMaterial.phpapp/Models/Foundation/Summit/SponsorStatistics.phpapp/Models/Foundation/Summit/SummitLeadReportSetting.phpapp/Models/Foundation/Summit/SummitSponsorship.php
🚧 Files skipped from review as they are similar to previous changes (1)
- app/Models/Foundation/Summit/ExtraQuestions/SummitSponsorExtraQuestionType.php
| public function getSponsor(): ?Sponsor | ||
| { | ||
| return $this->sponsor; | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect known call sites from current context.
fd -i 'SponsorUserInfoGrantService.php' app --exec sed -n '220,260p' {}
fd -i 'SponsorBadgeScanSerializer.php' app --exec sed -n '50,95p' {}
# Find direct dereferences after getSponsor() (unsafe with nullable contracts).
rg -nP --type=php '\->getSponsor\(\)\s*->' app
# Find getSponsor() passed as arguments for manual nullable-acceptance checks.
rg -nP --type=php '\->getSponsor\(\)\s*[,\)]' appRepository: OpenStackweb/summit-api
Length of output: 5085
Fix unguarded getSponsor() dereferences that assume non-null return.
The following locations directly dereference getSponsor() results without null checks and will fail if sponsor is null:
app/ModelSerializers/Summit/Registration/PromoCodes/SponsorSummitRegistrationDiscountCodeSerializer.php:66—$code->getSponsor()->getCompany()->getName()app/ModelSerializers/Summit/Registration/PromoCodes/SponsorSummitRegistrationPromoCodeSerializer.php:67—$code->getSponsor()->getCompany()->getName()
Add null checks or use hasSponsor() guards (as done in SponsorBadgeScanSerializer.php:69) before dereferencing. Alternatively, adjust callers to handle null values explicitly.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@app/Models/Foundation/Summit/SponsorStatistics.php` around lines 69 - 72, The
serializers dereference $code->getSponsor()->getCompany()->getName() without
guarding for a null sponsor; update
SponsorSummitRegistrationDiscountCodeSerializer and
SponsorSummitRegistrationPromoCodeSerializer to check $code->hasSponsor() (or
$code->getSponsor() !== null) before calling getCompany()/getName(), mirroring
the pattern used in SponsorBadgeScanSerializer::hasSponsor(); if no sponsor,
return a safe fallback (e.g., null or empty string) or handle it explicitly in
the serialized output so the code never calls getCompany() on a null Sponsor.
…:getSponsor (#531) * fix(audit): allow nullable sponsor in SummitSponsorExtraQuestionType::getSponsor Signed-off-by: romanetar <roman_ag@hotmail.com> * fix: update getSponsor return allowing nulls Signed-off-by: romanetar <roman_ag@hotmail.com> * chore(unit-tests): fix location venue generator * chore(unit-test): add regresion test --------- Signed-off-by: romanetar <roman_ag@hotmail.com> Co-authored-by: smarcet <smarcet@gmail.com>
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/summit-api/openapi/pr-531/ This page is automatically updated on each push to this PR. |
ref https://app.clickup.com/t/86b9ca05g
Summary by CodeRabbit