[GH-ISSUE #671] Invalid version string "8.x-1.x-dev" #4703

Closed
opened 2026-06-13 13:02:35 -05:00 by GiteaMirror · 5 comments
Owner

Originally created by @jderusse on GitHub (Feb 25, 2021).
Original GitHub issue: https://github.com/semver/semver/issues/671

When analyzing a composer.lock file sent by customer, I discovered this package:

        {
            "name": "foo/bar",
            "version": "8.x-1.x-dev",
            "...": "truncated"
        }

When parsing the version, Semver throws an UnexpectedValueException.

note: This exception, is also thrown when running $composer->getLocker()->getLockedRepository() when the ArrayLoader is loading the package.

So, I wonder, if this is a legitimate version, and if we should patch Semver?

Originally created by @jderusse on GitHub (Feb 25, 2021). Original GitHub issue: https://github.com/semver/semver/issues/671 When analyzing a `composer.lock` file sent by customer, I discovered this package: ```json { "name": "foo/bar", "version": "8.x-1.x-dev", "...": "truncated" } ``` When parsing the version, Semver throws an `UnexpectedValueException`. note: This exception, is also thrown when running `$composer->getLocker()->getLockedRepository()` when the `ArrayLoader` is loading the package. So, I wonder, if this is a legitimate version, and if we should patch Semver?
Author
Owner

@jjlharrison commented on GitHub (Feb 25, 2021):

I think https://github.com/npm/node-semver would be the correct repository for this issue. This repository is for the semver specification.

<!-- gh-comment-id:786063810 --> @jjlharrison commented on GitHub (Feb 25, 2021): I think https://github.com/npm/node-semver would be the correct repository for this issue. This repository is for the semver specification.
Author
Owner

@ljharb commented on GitHub (Feb 25, 2021):

Not node; composer is PHP.

<!-- gh-comment-id:786079196 --> @ljharb commented on GitHub (Feb 25, 2021): Not node; composer is PHP.
Author
Owner

@steveklabnik commented on GitHub (Feb 25, 2021):

Yes, this bug should be compiled against composer, not against the specification. Thank you!

<!-- gh-comment-id:786144621 --> @steveklabnik commented on GitHub (Feb 25, 2021): Yes, this bug should be compiled against composer, not against the specification. Thank you!
Author
Owner

@steveklabnik commented on GitHub (Feb 25, 2021):

(on a non-procedural note: this is not a valid semver version. Now, usually what is put into files is a range, not a version, and ranges are not technically in the semver spec yet. https://github.com/semver/semver/pull/584 is the current draft of the proposal for adding it to the spec. I still have not had the time to actually review it yet. 2020 was quite the year. but it is likely (though I haven't used composer so i can't be 100% sure) that you'd want to compare this to that, but you'd really need the composer maintainers to say. it is very clearly not a semver version though. given this is in a lockfile, maybe this is a version, and so that would be some sort of bug in composer)

<!-- gh-comment-id:786145603 --> @steveklabnik commented on GitHub (Feb 25, 2021): (on a non-procedural note: this is not a valid semver version. Now, usually what is put into files is a *range*, not a *version*, and ranges are not technically in the semver spec yet. https://github.com/semver/semver/pull/584 is the current draft of the proposal for adding it to the spec. I still have not had the time to actually review it yet. 2020 was quite the year. but it is likely (though I haven't used composer so i can't be 100% sure) that you'd want to compare this to that, but you'd really need the composer maintainers to say. it is very clearly not a semver version though. given this is in a lockfile, maybe this *is* a version, and so that would be some sort of bug in composer)
Author
Owner

@jderusse commented on GitHub (Feb 25, 2021):

oh sorry about the wrong repo

<!-- gh-comment-id:786155934 --> @jderusse commented on GitHub (Feb 25, 2021): oh sorry about the wrong repo
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/semver#4703