Skip to content

tests: test suite break when path contains # #551

Closed

Description

@hseg

Building from https://aur.archlinux.org/packages/python-cyclonedx-lib, I am getting ~400 errors if the path to the project contains a # character.
Log attached
error.log

Activity

  1. jkowalleck commented on Feb 14, 2024

    @jkowalleck
    Member

    Could you provide a reproducible setup/example?

  2. jkowalleck commented on Feb 14, 2024

    @jkowalleck
    Member

    dug into https://github.com/CycloneDX/cyclonedx-python-lib/files/14281372/error.log

    line of interest:

    ======================================================================
    ERROR: test_cases_render_valid_05_XML_1_5 (tests.test_enums.TestEnumComponentScope.test_cases_render_valid_05_XML_1_5)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/usr/lib/python3.11/site-packages/ddt.py", line 221, in wrapper
        return func(self, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/unittest/mock.py", line 1375, in patched
        return func(*newargs, **newkeywargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/tmp/tmp#Le1C31tGnA/python-cyclonedx-lib/src/cyclonedx-python-lib-6.4.1/tests/test_enums.py", line 256, in test_cases_render_valid
        super()._test_cases_render(bom, of, sv)
      File "/tmp/tmp#Le1C31tGnA/python-cyclonedx-lib/src/cyclonedx-python-lib-6.4.1/tests/test_enums.py", line 145, in _test_cases_render
        validation_errors = make_schemabased_validator(of, sv).validate_str(output)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/tmp/tmp#Le1C31tGnA/python-cyclonedx-lib/src/cyclonedx-python-lib-6.4.1/cyclonedx/validation/xml.py", line 61, in validate_str
        return self._validata_data(
               ^^^^^^^^^^^^^^^^^^^^
      File "/tmp/tmp#Le1C31tGnA/python-cyclonedx-lib/src/cyclonedx-python-lib-6.4.1/cyclonedx/validation/xml.py", line 67, in _validata_data
        validator = self._validator  # may throw on error that MUST NOT be caught
                    ^^^^^^^^^^^^^^^
      File "/tmp/tmp#Le1C31tGnA/python-cyclonedx-lib/src/cyclonedx-python-lib-6.4.1/cyclonedx/validation/xml.py", line 91, in _validator
        self.__validator = XMLSchema(file=schema_file)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "src/lxml/xmlschema.pxi", line 89, in lxml.etree.XMLSchema.__init__
    lxml.etree.XMLSchemaParseError: element decl. '{http://cyclonedx.org/schema/bom/1.5}id', attribute 'type': The QName value '{http://cyclonedx.org/schema/spdx}licenseId' does not resolve to a(n) type definition., line 644
    

    It appears, that XMLSchema()'s file argument must not include a #, as it would be stripped, since the path is treated as a url.

    I need to check with the leveraged https://pypi.org/project/lxml/ project, maybe there is a fix, or workaround, or an existing report/solution/advice.

  3. added
    CTContinuous Testing
    and removed
    questionFurther information is requested
    on Feb 14, 2024
  4. changed the title [-]Tests break when path contains #[/-] [+]tests: test suite break when path contains `#`[/+] on Feb 14, 2024
  5. jkowalleck commented on Feb 14, 2024

    @jkowalleck
    Member

    Thank you for your report, @hseg

    Since this project is community-driven, and contributions are welcome, I would ask you: are you interested in providing a solution to the problem? If so, please let me know. Please see our contribution guideline.

  6. hseg commented on Feb 14, 2024

    @hseg
    Author
  7. hseg commented on Feb 14, 2024

    @hseg
    Author
  8. jkowalleck commented on Feb 14, 2024

    @jkowalleck
    Member

    re: #551 (comment)
    Thanks for providing the setup snippet. this should make it easy for others to work on this issue.

    re: #551 (comment)
    I flagged this issue as "help wanted" as in "this is free for contributors".
    Whoever wants to tackle it, just drop a note here to let the others know.

  9. hseg commented on Apr 30, 2024

    @hseg
    Author
  10. hseg commented on May 26, 2024

    @hseg
    Author

    I've run a couple of exhaustive tests trying to find the forbidden patterns.
    Data is attached below. From it, I conjencture that besides #, it is also forbidden to have paths containing %xx where x are hexadecimal characters (though I've only checked lowercase...), excepting the following accepted hexadecimal sequences:

    • %01..%19
    • %20,%22,%23,%25,%60
    • %80..%99
      These can't be referring to control characters, otherwise eg %0a..%0f, %1a..1f would've been accepted. However, I do note that the second sequence of accepted characters corresponds to
    • "
    • #
    • %
    • `
      respectively. Perhaps someone can make better use of this data than me.

    failures-sorted.log
    successes-sorted.log

  11. jkowalleck commented on May 26, 2024

    @jkowalleck
    Member

    looks like these chars are all XML special chars.
    makes sense, since the XML tooling crashes when it tries to resolve paths ...

  12. hseg commented on May 26, 2024

    @hseg
    Author
  13. CAOShurong commented on Aug 12, 2026

    @CAOShurong
    Contributor

    Confirmed on current main (8edee5c) with Python 3.12, lxml 5.3.2, and libxml2 2.12.10 under WSL2: loading the bundled schemas from a checkout path containing # fails because the relative spdx.SNAPSHOT.xsd import is not resolved. The same regression test passes with lxml 6.1.1.

    I am preparing a narrow fix that passes an encoded local file: URI to XMLSchema, plus a regression test. I will link the PR to this issue when it is ready.

  14. jkowalleck commented on Aug 12, 2026

    @jkowalleck
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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