Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GoCD 15.2's config schema (cruise-config.xsd) causes validation errors #1489

Closed
pepoirot opened this issue Sep 15, 2015 · 3 comments

Comments

Projects
None yet
5 participants
@pepoirot
Copy link

commented Sep 15, 2015

Context

A local build is used to validate changes to a shared Go instance's configuration before it is applied.

Problem

Since switching from Go 14.2.0 to 15.2.0, the configuration of the Go config now fails to validate against the official schema (cruise-config.xsd).

The error is reproducible on either Mac (10.10.5) or Linux (Centos 6) with an empty configuration:

Centos 6 (libxml 2.6.26):

$ uname -rs
Linux 2.6.18-404.el5

$ xmllint --version 2>&1 | grep -Eo "libxml version [0-9]+"
libxml version 20626

$ curl -s https://raw.githubusercontent.com/gocd/gocd/15.2.0/config/config-server/resources/cruise-config.xsd > cruise-config-15.2.0.xsd

$ cat > test.xml << EOF
<?xml version="1.0"?>
<cruise xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="cruise-config.xsd" schemaVersion="75">
</cruise>
EOF

$ xmllint --noout --schema ./cruise-config-15.2.0.xsd ./test.xml
./cruise-config-15.2.0.xsd:856: element complexType: Schemas parser error : complex type 'onCancelType': The content model is not determinist.
WXS schema ./cruise-config-15.2.0.xsd failed to compile

MacOS 10.10.5 (libxml 2.9.0):

$ uname -rs
Darwin 14.5.0

$ xmllint --version 2>&1 | grep -Eo "libxml version [0-9]+"
libxml version 20900

$ curl -s https://raw.githubusercontent.com/gocd/gocd/15.2.0/config/config-server/resources/cruise-config.xsd > cruise-config-15.2.0.xsd

$ cat > test.xml << EOF
<?xml version="1.0"?>
<cruise xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="cruise-config.xsd" schemaVersion="75">
</cruise>
EOF

$ xmllint --noout --schema ./cruise-config-15.2.0.xsd ./test.xml
cruise-config-15.2.0.xsd:856: element complexType: Schemas parser error : complex type 'onCancelType': The content model is not determinist.
WXS schema cruise-config-15.2.0.xsd failed to compile

MacOS 10.10.5 (Java 8):

$ uname -rs
Darwin 14.5.0

$ java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

$ git clone -q -b master https://github.com/amouat/xsd-validator

$ ./xsd-validator/xsdv.sh ./cruise-config-15.2.0.xsd ./test.xml
Error reading XML Schema: ./cruise-config-15.2.0.xsd
cos-nonambig: baseTask and WC[##any] (or elements from their substitution group) violate "Unique Particle Attribution". During validation against this schema, ambiguity would be created for those two particles.

Potential causes

libxml: The content model is not determinist

From Deterministic and Non-Deterministic Schemas, the two alternatives in the xsd:choice in the Go 15.2.0's complexType definition would match a <task> sub-element.

<xsd:complexType name="onCancelType">
        <xsd:sequence>
            <xsd:choice>
                <xsd:element ref="baseTask" minOccurs="0" maxOccurs="1"/>
                <xsd:any minOccurs="0" maxOccurs="1"/>
            </xsd:choice>
        </xsd:sequence>
    </xsd:complexType>
Java8: baseTask and WC[##any] [...] violate "Unique Particle Attribution"

From Unique Particle Attribution, the cause appears identical. A <task> sub-element in a <oncancel>...</oncancel> node would match both alternatives (<xsd:element ref="baseTask" ...>) or <xsd:any ...>.

Workaround

Removing the second alternate (<xsd:any minOccurs="0" maxOccurs="1"/>) in the onCancelType declaration fixes the issue with libxml:

$ diff -U4 ./cruise-config-15.2.0.xsd ./cruise-config-15.2.0-modified.xsd
--- ./cruise-config-15.2.0.xsd  2015-09-14 15:00:10.000000000 +1000
+++ ./cruise-config-15.2.0-modified.xsd 2015-09-14 15:10:30.000000000 +1000
@ -856,9 +856,8 @@
     <xsd:complexType name="onCancelType">
         <xsd:sequence>
             <xsd:choice>
                 <xsd:element ref="baseTask" minOccurs="0" maxOccurs="1"/>
-                <xsd:any minOccurs="0" maxOccurs="1"/>
             </xsd:choice>
         </xsd:sequence>
     </xsd:complexType>
     <xsd:element name="oncancel" type="onCancelType"/>

$ xmllint --noout --schema ./cruise-config-15.2.0-modified.xsd ./test.xml
./test.xml validates

With Java8, the issue remains because the taskType declaration is also ambiguous:

<xsd:complexType name="tasksType">
    <xsd:sequence>
        <xsd:element minOccurs="0" maxOccurs="unbounded" ref="baseTask"/>
        <xsd:any minOccurs="0" maxOccurs="unbounded"/>
    </xsd:sequence>
</xsd:complexType>
@rusio

This comment has been minimized.

Copy link

commented Oct 2, 2015

We see another validation error on our schemaVersion=75 against the current schema published at this URL: http://www.go.cd/documentation/user/current/resources/cruise-config.xsd, which fixes this value to 72.

If you compare the published schema on the above URL with the one that is installed on the Go-Server via the current 15.2 RPM: http://download.go.cd/gocd-rpm/go-server-15.2.0-2248.noarch.rpm you will see many additions in the 75 version.

So it seems the schema, which is published on the above URL must be updated by the site admins.

varshavaradarajan added a commit to varshavaradarajan/gocd that referenced this issue Jan 4, 2016

varshavaradarajan added a commit to varshavaradarajan/gocd that referenced this issue Jan 4, 2016

varshavaradarajan added a commit to varshavaradarajan/gocd that referenced this issue Jan 4, 2016

@arvindsv arvindsv modified the milestone: Unknown - Needs interest from someone Jan 4, 2016

varshavaradarajan added a commit to varshavaradarajan/gocd that referenced this issue Jan 5, 2016

varshavaradarajan added a commit to varshavaradarajan/gocd that referenced this issue Jan 5, 2016

varshavaradarajan added a commit to varshavaradarajan/gocd that referenced this issue Jan 5, 2016

Issue gocd#1489 - Added test to validate the number of on-cancel tasks.
Issue gocd#1489 - Removed the ambiguous line frome cruise-config.xsd.
Issue gocd#1489 - Removed mailhost and security tags from the xml string.
Issue gocd#1489 - Changed to ExpectedException.
Issue gocd#1489 - Added a configuration migration.
Issue gocd#1486 - Changed the year in license.

varshavaradarajan added a commit to varshavaradarajan/gocd that referenced this issue Jan 5, 2016

Issue gocd#1489 - Added test to validate the number of on-cancel tasks.
Issue gocd#1489 - Removed the ambiguous line frome cruise-config.xsd.
Issue gocd#1489 - Removed mailhost and security tags from the xml string.
Issue gocd#1489 - Changed to ExpectedException.
Issue gocd#1489 - Added a configuration migration.
Issue gocd#1486 - Changed the year in license.
Changed schema version in xsl.

varshavaradarajan added a commit to varshavaradarajan/gocd that referenced this issue Jan 6, 2016

Issue gocd#1489 - Added test to validate the number of on-cancel tasks.
Issue gocd#1489 - Removed the ambiguous line frome cruise-config.xsd.
Issue gocd#1489 - Removed mailhost and security tags from the xml string.
Issue gocd#1489 - Changed to ExpectedException.
Issue gocd#1489 - Added a configuration migration.
Issue gocd#1486 - Changed the year in license.
Changed schema version in xsl.
Issue gocd#1489 - Added proper copyright headers as per the template.

varshavaradarajan added a commit to varshavaradarajan/gocd that referenced this issue Jan 6, 2016

Validate the number of on-cancel tasks (gocd#1489)
* Removed the ambiguous line frome cruise-config.xsd.
* Changed to ExpectedException.
* Added a configuration migration.
* Changed schema version in xsl.
* Added proper copyright headers as per the template.

ketan added a commit that referenced this issue Jan 6, 2016

Merge pull request #1749 from varshavaradarajan/issues
Issue #1489 - Added test to validate the number of on-cancel tasks.

@ketan ketan modified the milestones: Release 16.1, Release: Unknown Jan 6, 2016

varshavaradarajan added a commit to varshavaradarajan/gocd that referenced this issue Jan 6, 2016

varshavaradarajan added a commit to varshavaradarajan/gocd that referenced this issue Jan 6, 2016

ketan added a commit that referenced this issue Jan 6, 2016

Merge pull request #1759 from varshavaradarajan/issues
Related to (#1489) - fixed another xsd-validation issue.
@rajiesh

This comment has been minimized.

Copy link
Contributor

commented Jan 15, 2016

verified on 16.1.0-2855 cruise-config.xsd with schemaVersion 77 and the xml validation using xmllint is successful

@arvindsv

This comment has been minimized.

Copy link
Member

commented Jan 15, 2016

Closing this since it seems to be fixed.

@arvindsv arvindsv closed this Jan 15, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.