Skip to content

Improve exception "Cannot invoke "String.hashCode()" because "<local6>" is null" #16

@erosb

Description

@erosb

This happens when a parameters's schemas doesn't contain "type" (eg. it is a const or an enum). Then Kappa can't figure out what primitive type should the convert it to. The exception message could be more friendly in the first place.

A better fix would be adding lenient mode support to json-sKema so that the parameter could always be a string, no need to figure out anything. Then an instance like "0" would pass validation against a {"type": "number"} schema.

Stacktrace:

java.lang.NullPointerException: Cannot invoke "String.hashCode()" because "<local6>" is null
	at com.github.erosb.kappa.operation.validator.util.convert.TypeConverter.convertPrimitive(TypeConverter.java:111)
	at com.github.erosb.kappa.operation.validator.util.convert.style.StyleConverter.convert(StyleConverter.java:33)
	at com.github.erosb.kappa.operation.validator.util.convert.style.SimpleStyleConverter.convert(SimpleStyleConverter.java:24)
	at com.github.erosb.kappa.operation.validator.util.convert.ParameterConverter.pathToNode(ParameterConverter.java:123)
	at com.github.erosb.kappa.operation.validator.validation.OperationValidator.validatePath(OperationValidator.java:163)
	at com.github.erosb.kappa.operation.validator.validation.RequestValidator.validate(RequestValidator.java:264)
	at com.github.erosb.kappa.operation.validator.validation.RequestValidator.validate(RequestValidator.java:169)
	at com.github.erosb.kappa.operation.validator.validation.RequestValidator.validate(RequestValidator.java:126)

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