Skip to content

Conversation

Izumi-kun
Copy link
Contributor

Motivation

The primary reason for these changes is to attempt a workaround for an annoying bug in JetBrains' IDE.

Background

I create private packages that are distributed via archives (using the artifact repository type). As a result, I need to specify the version of the packages directly in the composer.json file.

What's wrong

PhpStorm considers the version 1.0.0-dev as invalid, displaying the error: "String violates the pattern: '^v?\d+(.\d+){0,3}|^dev-'".
In my opinion, the reason for this behavior is an incorrect implementation of the pattern matcher:

https://github.com/JetBrains/intellij-community/blob/33099feb7000ed4f798ba3f34fd28c08518c96cf/json/src/com/jetbrains/jsonSchema/impl/light/legacy/JsonSchemaObjectReadingUtils.java#L355-L386

  1. It uses the matches() method (which attempts to match the entire region against the pattern) instead of find().
  2. It uses a suspicious adaptSchemaPattern() method, which "adapts" the original pattern and is incompatible with alternation (such as ^v?\d+(\.\d+){0,3}|^dev-).

Solution

  1. According to the Composer documentation, valid suffixes should be added to the pattern.
  2. Following the JSON Schema reference, the regular expression is surrounded by ^...$.

@Seldaek Seldaek added this to the 2.8 milestone Mar 6, 2025
@Seldaek Seldaek merged commit 71e8395 into composer:main Mar 6, 2025
20 checks passed
@Seldaek
Copy link
Member

Seldaek commented Mar 6, 2025

Thanks yeah I was trying to keep this short for simplicity but if it causes problems it's worth expanding it 👍🏻

Copy link

@changeschung changeschung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Braaavooo 😂💥

@Seldaek
Copy link
Member

Seldaek commented Apr 4, 2025

@changeschung the only way to never break anything is to stop moving forward. Shit happens, no reason to make fun of people.

@Izumi-kun
Copy link
Contributor Author

Oops... It looks like the version format is actually more flexible than what’s in the docs. Ideally, we should update them to avoid confusion — though nailing down the exact wording might be a little tricky.

@changeschung
Copy link

And when did I? Where did I? Dude?

@changeschung
Copy link

R u on drugs?

@Seldaek
Copy link
Member

Seldaek commented Apr 4, 2025

Yeah I don't really want to document all the horrible formats people use to avoid promoting them, but we do have to support them for BC reasons :)

@dbpolito
Copy link

dbpolito commented Apr 4, 2025

This PR broke repositories with type path (https://getcomposer.org/doc/05-repositories.md#path) on versions 2.8.8 and 2.8.7, i had to downgrade to 2.8.6.

@xabbuh
Copy link
Contributor

xabbuh commented Apr 4, 2025

@dbpolito In what way does it break using path repositories? It’s probably best to open a new issue with some details about what you observe under what circumstances.

@dbpolito
Copy link

dbpolito commented Apr 4, 2025

nvm, not related to this one, but somehow this version got more strict, because i had this:

image

and the error was missleading:

image

only below it also mentions the symlink being wrong... anyway, i fixed on my end and not related to this one...

thanks

@Seldaek
Copy link
Member

Seldaek commented Apr 4, 2025

Yeah that is a good improvement tho, it caught a misconfiguration.

@shaesen
Copy link

shaesen commented May 3, 2025

Hello, Since installation of Composer 2.8.8 I get this error when running composer diagnose:

Checking composer.lock: FAIL
packages[121].version : Does not match the regex pattern ^v?\d+(?:[.-]\d+){0,3}[._-]?(?:(?:stable|beta|b|RC|rc|alpha|a|patch|pl|p)(?:(?:[.-]?\d+)+)?)?(?:[.-]?dev|.x-dev)?(?:+.)?$|^dev-.*$

How can I get rid of this FAIL ? I tried looking for 'packages[121].version' string and substring in the composer .lock file but did not find anything matching. Where is the fault and how can I fix it ?

I have the same erron on another site with 'packages[110].version'

@xabbuh
Copy link
Contributor

xabbuh commented May 4, 2025

Maybe that's related to #12376 not being released yet. Does the issue persist when updating Composer with composer self-update --snapshot?

@shaesen
Copy link

shaesen commented May 4, 2025

I cannot self-update composer, it is managed by the provider ... I'll have to wait for them to update composer :(

The issue is not occuring on any of my local sites ...

@Seldaek
Copy link
Member

Seldaek commented May 13, 2025

Ok https://github.com/composer/composer/releases/tag/2.8.9 is now out sorry for the delay.

kayw-geek pushed a commit to kayw-geek/composer that referenced this pull request Aug 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants