Skip to content

Guard against null first record and null/blank fieldApiName#6

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/add-type-checking-for-records
Draft

Guard against null first record and null/blank fieldApiName#6
Copilot wants to merge 2 commits into
mainfrom
copilot/add-type-checking-for-records

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 3, 2026

getFirstValue would throw a NullPointerException if the first element of records was null, and could produce unexpected behavior if fieldApiName was null or blank — neither case was handled.

Changes

  • Null first-record guard — checks records[0] == null before calling .get(), returning null instead of crashing
  • Null/blank fieldApiName guard — uses String.isBlank() to short-circuit before the field lookup
  • Both guards are consolidated into a single condition to avoid duplication:
if (firstRecord == null || String.isBlank(req.fieldApiName)) {
    resp.response = null;
    results.add(resp);
    continue;
}
  • New teststestGetFirstValue_NullFirstRecord, testGetFirstValue_NullFieldApiName, testGetFirstValue_BlankFieldApiName

Copilot AI changed the title [WIP] Add type checking for non-SObject types in records list Guard against null first record and null/blank fieldApiName Apr 3, 2026
Copilot AI requested a review from ethandunzer April 3, 2026 17:54
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.

No Handling for Non-SObject Types in Records List

2 participants