Skip to content

fix: prevent TypeError when parsing null object in CLI (#153)#1673

Open
2k33cse992574 wants to merge 2 commits into
appwrite:mainfrom
2k33cse992574:fix/cli-null-value-crash-153-real
Open

fix: prevent TypeError when parsing null object in CLI (#153)#1673
2k33cse992574 wants to merge 2 commits into
appwrite:mainfrom
2k33cse992574:fix/cli-null-value-crash-153-real

Conversation

@2k33cse992574

Copy link
Copy Markdown

Fixes appwrite/sdk-for-cli#153

Re-opening this PR from #1662 because the Git commit history of the original branch became orphaned during a force-push.

This PR prevents a TypeError in the CLI parsing logic and includes ONLY the targeted null-guards in templates/cli/lib/parser.ts as requested by the maintainers.

@greptile-apps

greptile-apps Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds two null-safety guards to templates/cli/lib/parser.ts to prevent TypeErrors when the CLI parser encounters null values in API responses.

  • Adds if (obj == null) return result; at the top of filterObject so that null values passed through filterData's array-mapping path no longer throw a TypeError: Cannot convert undefined or null to object.
  • Replaces the first-element-only typeof section.value[0] === "object" heuristic with section.value.some(item => item !== null && typeof item === "object"), correctly routing arrays that start with null but contain real objects into drawTable rather than drawScalarArray.

Confidence Score: 5/5

The changes are minimal, targeted null-safety guards with no new logic paths or side effects.

Both changes are straightforward defensive guards: the filterObject early return on null is harmless (the existing caller already avoids passing null, so this is pure defense-in-depth), and the .some() replacement correctly handles arrays whose first slot is null while drawTable already tolerates null entries via toJsonObject(maskedItem) ?? {}.

No files require special attention.

Important Files Changed

Filename Overview
templates/cli/lib/parser.ts Two targeted null-safety fixes: null guard in filterObject and replacement of first-element heuristic with .some() scan for mixed/null-leading arrays

Reviews (2): Last reviewed commit: "fix: use some() and == null for parser h..." | Re-trigger Greptile

Comment thread templates/cli/lib/parser.ts Outdated
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.

🐛 Bug Report: appwrite function get-execution crashes with TypeError

1 participant