Skip to content

🐛 Fix: disallow need variants for list type fields #1489

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

Merged
merged 6 commits into from
Aug 11, 2025

Conversation

chrisjsewell
Copy link
Member

@chrisjsewell chrisjsewell commented Aug 8, 2025

The variant processing was turning these into strings, rather than list of strings, which does not make sense and breaks the need item schema.

Since this is the case, and has not been noticed before, it is doubtful that variants are ever used in this context.

The variant processing was turning these into strings,
which does not make sense and breaks the need item schema.

Since this is the case, and has not been noticed before,
it is doubtful that variants were ever used in this context.
@chrisjsewell chrisjsewell requested a review from ubmarco August 8, 2025 10:33
Copy link

codecov bot commented Aug 8, 2025

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 88.66%. Comparing base (4e10030) to head (a7f6ee6).
⚠️ Report is 147 commits behind head on master.

Files with missing lines Patch % Lines
sphinx_needs/functions/functions.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1489      +/-   ##
==========================================
+ Coverage   86.87%   88.66%   +1.78%     
==========================================
  Files          56       68      +12     
  Lines        6532     8451    +1919     
==========================================
+ Hits         5675     7493    +1818     
- Misses        857      958     +101     
Flag Coverage Δ
pytests 88.66% <66.66%> (+1.78%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@ubmarco ubmarco left a comment

Choose a reason for hiding this comment

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

So this is a good observation. Really seems like it was only working for options as match_variants returns str | None, so you have a fair point. I will approve this as it makes SN safer.
However I think variant handling is a powerful feature, also for links.
I am ok for disabling this for now and listen to user's feedback whether link variants are a thing.
@danwos marking you so you are aware of this

@danwos
Copy link
Member

danwos commented Aug 8, 2025

I have seen once a use case, where variant management was needed for links, as the user wanted to link a spec to 2 different requirements, which were coming from 2 OEMs.
This was a platform project, used by multiple customers, which all delivered their own list of requirements. And it's a valid, often told use case for platform projects.

Would it cost much time to fix it instead of deactivating it?
It's one feature less for Sphinx-Needs :(

@chrisjsewell
Copy link
Member Author

chrisjsewell commented Aug 11, 2025

Would it cost much time to fix it instead of deactivating it?

The question is; what does this syntax even mean, in terms of a list of strings?

For example here; :links: [tag]:some|thing, other|wise,
are some|thing / other|wise single link references,
or a list of references; ["some", "thing"], and how does these even integrate with the initial parsing of these strings.

The idea of variants is not necessarily bad, but the implementation is a complete ill-though out mess.

I will be disabling this for now,
but a next step is to move the initial identification/parsing of dynamic functions and variants to the need item creation phase (e.g. when a directive is parsed),
and then we will better be able to implement/orchestrate the parsing of string lists / dynamic functions / variant functions and how they interact together

@chrisjsewell chrisjsewell merged commit 4250433 into master Aug 11, 2025
20 checks passed
@chrisjsewell chrisjsewell deleted the disallow-variant-links branch August 11, 2025 08:48
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.

3 participants