Skip to content

![high](https://www.gstatic.com/codereviewagent/high-priority.svg) #38

@ghost

Description

high

The current implementation will throw an exception if 'question' or 'options' fields are missing in the YAML data. To make the parsing more robust and prevent potential server crashes from malformed content, consider handling null values by providing defaults (e.g., an empty string for the question and an empty list for options).

Question parseQuestion(YamlMap map) {
  return Question(
    parseMarkdownToHtml((map['question'] as String?) ?? '', inline: true),
    ((map['options'] as List<Object?>?) ?? [])
        .map((e) => parseAnswer(e as YamlMap))
        .toList(),
  );
}

最初由 @gemini-code-assist[bot] 在 dart-lang/site-www#7085 (comment) 发布

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions