question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Constraints not enforced where `workspace_field ` is absent

See original GitHub issue
  • I’d be willing to implement a fix

Describe the bug Creating a constraint using the query predicate to enforce the fact for workspace manifests where a field does not exist. Running yarn constraints does not enforce the constraint.

To Reproduce Seem minimal reproduction here https://github.com/theseyi/constraints

  • init a yarn workspace with one workspace package packages/package-a and the workspace root
  • import the constraint plugin yarn plugin import constraints
  • touch a constraints.pro file and add in the following constraint
  • attempt to enforce the constraint with yarn constraints
% enforce workspace packages without a workspace field to have a scripts.test field
gen_enforced_field(WorkspaceCwd, 'scripts.test', 'someValue') :-
  workspace_field(WorkspaceCwd, 'workspaces', null).
Reproduction
// in workspace root
{
  "name": "constraints",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "workspaces": [
    "packages/*"
  ]
}
// in packages/package-a
{
  "name": "package-a",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT"
}
% enforce workspace packages without a workspace field to have a scripts.test field
gen_enforced_field(WorkspaceCwd, 'scripts.test', 'someValue') :-
  workspace_field(WorkspaceCwd, 'workspaces', null).

Expected:

➤ YN0037: package-a must have a field scripts.test set to someValue, but doesn't
➤ YN0000: Failed with errors in 0s 18ms

IMPORTANT: We strongly prefer reproductions that use Sherlock. Please check our documentation for more information: https://yarnpkg.com/advanced/sherlock

Unable to use Sherlock here since I’m not familiar with running it over prolog

Environment if relevant (please complete the following information):

  • OS: macos
  • Node version v12.20.1
  • Yarn version 2.4.0

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
merceyzcommented, Jan 28, 2021

You can update your constraint to check that it has any value and then negate it to get the result you’re after

gen_enforced_field(WorkspaceCwd, 'scripts.test', 'someValue') :-
  \+ workspace_field(WorkspaceCwd, 'workspaces', _).
0reactions
theseyicommented, Jan 29, 2021

Sure, will get to it today, thanks for following up

Read more comments on GitHub >

github_iconTop Results From Across the Web

New Workspace Field Type: Count Fields
In our next release, we're introducing a new type of custom workspace field that tallies data from other fields in native or dynamic ......
Read more >
San Diego Patch 1 - Product Documentation | ServiceNow
How search works: Punctuation and capital letters are ignored. Special characters like underscores (_) are removed.
Read more >
BUI for Administrators - Oracle Help Center
Note that the Chat workspace is not customizable for the Agent Browser UI. ... An arrow on a workspace field or control that...
Read more >
MySQL Bugs: #57904: Missing constraint from information ...
Bug #57904, Missing constraint from information schema ... This is the output from 5.5.7 followed by the output from 5.1.52.
Read more >
Bug List
27290, Platform, User Ass, platform-help-inbox, CLOS, WONT, ISC: The Toggle navigator key is missing on the content toolbar, 2002-12-03.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found