Skip to content

Breaking schema changes go unnoticed due broken $id references #2767

@apuig

Description

@apuig

Jenkins and plugins versions report

updating from 2.504 to 2.543

What Operating System are you using (both controller, and any agents involved in the problem)?

Linux

Reproduction steps

Schema validation fails to detect obsolete or invalid attributes in YAML configurations due to broken $id references in the generated JSON schema. This allows configurations with deprecated attributes to pass validation, only to fail at runtime after Jenkins upgrades.

For example, jenkinsci/jenkins#25918 removed client IP from CSRF crumb calculation.

  1. Use Jenkins 2.542 or earlier with JCasC plugin
  2. Create YAML configuration:
jenkins:
  crumbIssuer:
    standard:
      excludeClientIPFromCrumb: false
  1. Configuration loads successfully
  2. Upgrade to Jenkins 2.543+
  3. Validate with the new schema

Expected Results

  • The validation can catch this attribute is not longer expected.

  • A test like this should fail to indicate the breaking change.

Actual Results

  • Schema validation fails to spot the error, and then during load the expected error is thrown
io.jenkins.plugins.casc.UnknownAttributesException: standard: Invalid configuration elements for type: 
class hudson.security.csrf.DefaultCrumbIssuer : excludeClientIPFromCrumb.

Anything else?

The generated schema contains broken (no definitions section) $id references for (at least) HeteroDescribableCconfigurators:

"crumbIssuer": {
    "oneOf": [
        {
            "additionalProperties": false,
            "properties": {"standard": {"$id": "#/definitions/hudson.security.csrf.DefaultCrumbIssuer"}}
        },
        {
            "additionalProperties": false,
            "properties": {"test": {"$id": "#/definitions/org.jvnet.hudson.test.TestCrumbIssuer"}}
        }
    ],
    "type": "object"
},

This non-existent #/definitions/..., causes the validator to accept any properties, such as obsolete attributes (like excludeClientIPFromCrumb), typos or completely made-up properties.

An schema like this will more accurately describe the current crumb standar implementation:

"crumbIssuer": {"oneOf": [
    {
        "additionalProperties": false,
        "properties": {"standard": {
            "additionalProperties": false,
            "type": "object",
            "properties": {"excludeClientIPFromCrumb": {"type": "boolean"}}
        }}
    },
    {
        "additionalProperties": false,
        "properties": {"test": {
            "additionalProperties": false,
            "type": "object",
            "properties": {}
        }}
    }
]},

After the Jenkins upgrade, the attribute will be removed (leaving "properties": {}), which will effectively prevent any attributes there. As a result, the validJenkinsBaseConfigWithSymbol.yml test will fail, highlighting the breaking change


please note, oneOf should not uses "type": "object"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions