Severity: Medium
Type: Bug
Scope: Campaigns
Labels: bug, good first issue
Description
parseAcceptedAssets (src/campaigns/campaigns.service.ts, lines ~451–470) splits accepted asset strings on : and constructs { assetType: 'credit', code, issuer } only when both code and issuer are present. For inputs like "XLM:", "USDC:", or empty strings, parseAcceptedAssets returns null and the entry is .filter(Boolean)-dropped. If every entry is malformed, the function returns an empty array; the surrounding createCampaign logic then leaves Campaign.acceptedAssets unset, which downstream code treats as "native XLM only" (coerceAcceptedAssets in donations.service.ts).
A creator who types USDC:G...issuer... is fine, but USDC: (typo), USDC (missing issuer), XLM:badissuer (empty issuer) silently produce incorrect acceptance lists with no validation error.
Recommendation
- In the
CreateCampaignDto, use a @ValidateNested class with @IsString on both code and issuer, throwing BadRequestException for malformed inputs.
- Validate at the service boundary too: if any input has a colon and the right-hand side is empty (or vice versa), return
400.
- Cover with unit tests for the malformed-input matrix.
Severity: Medium
Type: Bug
Scope: Campaigns
Labels:
bug,good first issueDescription
parseAcceptedAssets(src/campaigns/campaigns.service.ts, lines ~451–470) splits accepted asset strings on:and constructs{ assetType: 'credit', code, issuer }only when bothcodeandissuerare present. For inputs like"XLM:","USDC:", or empty strings,parseAcceptedAssetsreturnsnulland the entry is.filter(Boolean)-dropped. If every entry is malformed, the function returns an empty array; the surroundingcreateCampaignlogic then leavesCampaign.acceptedAssetsunset, which downstream code treats as "native XLM only" (coerceAcceptedAssetsindonations.service.ts).A creator who types
USDC:G...issuer...is fine, butUSDC:(typo),USDC(missing issuer),XLM:badissuer(empty issuer) silently produce incorrect acceptance lists with no validation error.Recommendation
CreateCampaignDto, use a@ValidateNestedclass with@IsStringon bothcodeandissuer, throwingBadRequestExceptionfor malformed inputs.400.