Skip to content

better message on syntax error when parsing JBP_CONFIG_OPEN_JDK_JRE #268

@YannRobert

Description

@YannRobert

When I added the following line in env: section of the manifest yaml file

  JBP_CONFIG_OPEN_JDK_JRE: '[memory_calculator: {memory_heuristics: {heap: 70, metaspace: 15, native:10, permgen: 15, stack: 5}, memory_sizes: {metaspace: 128m..}}]'

I got the following error when pushing an app

Downloaded buildpacks
Staging...
/usr/lib/ruby/1.9.1/psych.rb:203:in `parse': (<unknown>): found unexpected ':' while scanning a plain scalar at line 1 column 67 (Psych::SyntaxError)
    from /usr/lib/ruby/1.9.1/psych.rb:203:in `parse_stream'
    from /usr/lib/ruby/1.9.1/psych.rb:151:in `parse'
    from /usr/lib/ruby/1.9.1/psych.rb:127:in `load'
    from /tmp/buildpacks/b60c1edb564d6e1ed1a20182eeb07d71/lib/java_buildpack/util/configuration_utils.rb:117:in `load_configuration'
    from /tmp/buildpacks/b60c1edb564d6e1ed1a20182eeb07d71/lib/java_buildpack/util/configuration_utils.rb:48:in `load'
    from /tmp/buildpacks/b60c1edb564d6e1ed1a20182eeb07d71/lib/java_buildpack/buildpack.rb:163:in `block in instantiate'
    from /tmp/buildpacks/b60c1edb564d6e1ed1a20182eeb07d71/lib/java_buildpack/buildpack.rb:154:in `map'
    from /tmp/buildpacks/b60c1edb564d6e1ed1a20182eeb07d71/lib/java_buildpack/buildpack.rb:154:in `instantiate'
    from /tmp/buildpacks/b60c1edb564d6e1ed1a20182eeb07d71/lib/java_buildpack/buildpack.rb:126:in `instantiate_components'
    from /tmp/buildpacks/b60c1edb564d6e1ed1a20182eeb07d71/lib/java_buildpack/buildpack.rb:120:in `initialize'
    from /tmp/buildpacks/b60c1edb564d6e1ed1a20182eeb07d71/lib/java_buildpack/buildpack.rb:225:in `new'
    from /tmp/buildpacks/b60c1edb564d6e1ed1a20182eeb07d71/lib/java_buildpack/buildpack.rb:225:in `with_buildpack'
    from /tmp/buildpacks/b60c1edb564d6e1ed1a20182eeb07d71/bin/compile:26:in `<main>'
Failed to compile droplet
Exit status 223
Staging failed: Exited with status 223

FAILED
BuildpackCompileFailed

Then when I change the env variable to

JBP_CONFIG_OPEN_JDK_JRE: '[memory_calculator: {memory_heuristics: {heap: 70, metaspace: 15, native: 10, permgen: 15, stack: 5}, memory_sizes: {metaspace: 128m..}}]'

then the deployment succeed as expected.

Notice the space after the colon in native: 10, compare to native:10 in the first example.

I think this can be generalized to :
the separator between an attribute name and an attribute value is required to be ": " (colon + space),
when the separator is ":" (colon) the buildpack will fail with the ruby error and stack trace during staging

This is a user input problem, but it would be nice to have this case be handled with an insightful error message, and no stack trace.
The message could be as simple as stating : Syntax error while parsing env variable JBP_CONFIG_OPEN_JDK_JRE : found unexpected ':' while scanning a plain scalar at line 1 column 67

The status Failed to compile droplet and BuildpackCompileFailed are also alarming and misleading, as they could be interpreted as a problem either in the buildpack or on the cloudfoundry service.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions