Skip to content

Add input validation for empty parameters in utility script #7932

@Vedavyasa21

Description

@Vedavyasa21

Actual Behavior

Description:
The function parseContent() in utils/parse.js (or similar helper file) doesn’t check for empty or undefined input before processing. This may cause unexpected errors if someone calls the function without arguments

The function parseContent() in utils/parse.js (or a similar helper file) doesn’t check for empty or undefined input before processing.
This can cause unexpected runtime errors when the function is called without valid content.

Example:
parseContent(); // Throws undefined error

Expected Behavior

Expected Behavior

The function should validate input and throw a clear, descriptive error when content is missing.
Expected output:
Error: Input content cannot be empty.
Suggested Fix:
Add a simple guard clause:
if (!content) {
throw new Error("Input content cannot be empty.");
}

On what browser(s) are you seeing the problem?

No response

Code of Conduct

  • By submitting this issue, I agree to follow Codecademy Doc's Code of Conduct.

For Maintainers

  • Labels added
  • Issue is assigned

Metadata

Metadata

Labels

bugSomething isn't workingclaimedIssue is claimed and closed to further assignmentenhancementNew feature or requestjavascriptJavaScript entries

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions