Fix for 'include' flag with spec file#1503
Merged
agrasth merged 1 commit intojfrog:masterfrom Dec 10, 2025
Merged
Conversation
6869f56 to
25f7f24
Compare
4 tasks
reshmifrog
requested changes
Dec 2, 2025
Contributor
|
Can you please check why the |
fbf4ed9 to
4171d50
Compare
Make Include field public to allow JSON unmarshaling from spec files and direct field access. This is cleaner and more consistent with other fields like Exclusions.
4171d50 to
0dfaccb
Compare
Contributor
reshmifrog
approved these changes
Dec 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fix: --include Flag Ignored When Using Spec Files in Search Command
Description
This PR fixes a bug where the
--includeflag is ignored when using a spec file with thejf rt searchcommand, causing all fields to be returned instead of only the fields specified in the--includeflag.Issue
When using the search command with a spec file and the
--includeflag, the result returns all the fields instead of returning only the fields specified in the--includeflag.Steps to Reproduce
spec.json):{ "files": [ { "aql": { "items.find": { "repo": "npm-remote-cache" } } } ] }jf rt search --spec=spec.json --include="name;repo" --limit=3Expected Behavior
Based on the documentation, when the
--includeflag is used, only the fields specified in the flag should be returned (along withpathwhich is always included, andpropswhich appears to always be included in the response).Impact
Customers cannot use the
--includefunctionality when they use a spec file, forcing them to either:jf rt search <repo_name> --include="<field_names>")Root Cause
The
OverrideFieldsIfSetfunction in three locations was missing the override for theincludefield:jfrog-cli-core/common/cliutils/spec.gojfrog-cli/utils/cliutils/utils.gojfrog-cli-core/plugins/common/config.goWhile the function properly overrides fields like
exclusions,props,transitive, etc., it was not handling theincludefield. Additionally, sinceincludeis a private field in theFilestruct, a setter method was needed to modify it from outside the package.Before the Fix
Command:
jf rt search --spec=spec.json --include="name;repo" --limit=3Response (ALL fields returned - BUG):
[ { "path": "npm-remote-cache/.npm/send/package.json", "type": "file", "size": 147586, "created": "2025-03-31T15:04:41.156Z", "modified": "2025-03-27T01:39:15.000Z", "sha1": "2208b57f076a5b5baefbcdb3d7c9f9ce8f068407", "sha256": "8d6764b2ff707e018af681f5bb644693aea293523fdd4e0e18f6e48f52563652", "md5": "171183574353643ddda46696efb4f963", "props": { "artifactory.internal.etag": [ "W/\"171183574353643ddda46696efb4f963\"" ] } }, { "path": "npm-remote-cache/.npm/jfrog-midgard/package.json", "type": "file", "size": 3064, "created": "2025-03-31T15:04:42.388Z", "modified": "2022-05-06T13:09:09.000Z", "sha1": "094abc56334ba4e15519e32e8309e99042bae49c", "sha256": "b0d8802958bb16a7c24bbcc231f91d27932ca6f812796eee9c5b4ea136176c6d", "md5": "e247404ece26afdc9cae84ae25ee6f51", "props": { "artifactory.internal.etag": [ "W/\"e247404ece26afdc9cae84ae25ee6f51\"" ] } }, { "path": "npm-remote-cache/.npm/debug/package.json", "type": "file", "size": 195840, "created": "2025-03-31T15:04:42.797Z", "modified": "2025-09-13T17:25:21.000Z", "sha1": "aa0be9552dd92666cd055b447d59d572ba6aecf6", "sha256": "7cd3d7bd97fdfb4af9fb90023decb619a19811c5e5aae94c3b66935cce37abae", "md5": "11050952da2ca49e2571ebcd3dfd554e", "props": { "artifactory.internal.etag": [ "W/\"11050952da2ca49e2571ebcd3dfd554e\"" ], "jf.origin.remote.path": [ "https://registry.npmjs.org/debug" ] } } ]After the Fix
Command:
jf rt search --spec=spec.json --include="name;repo" --limit=3Response (Limited fields only - FIXED):
[ { "path": "npm-remote-cache/.npm/send/package.json", "props": { "artifactory.internal.etag": [ "W/\"171183574353643ddda46696efb4f963\"" ] } }, { "path": "npm-remote-cache/.npm/jfrog-midgard/package.json", "props": { "artifactory.internal.etag": [ "W/\"e247404ece26afdc9cae84ae25ee6f51\"" ] } }, { "path": "npm-remote-cache/.npm/debug/package.json", "props": { "artifactory.internal.etag": [ "W/\"11050952da2ca49e2571ebcd3dfd554e\"" ], "jf.origin.remote.path": [ "https://registry.npmjs.org/debug" ] } } ]Additional Test with --include="path"
Command:
jf rt search --spec=spec.json --include="path" --limit=2Before (ALL fields returned):
[ { "path": "npm-remote-cache/.npm/send/package.json", "type": "file", "size": 147586, "created": "2025-03-31T15:04:41.156Z", "modified": "2025-03-27T01:39:15.000Z", "sha1": "2208b57f076a5b5baefbcdb3d7c9f9ce8f068407", "sha256": "8d6764b2ff707e018af681f5bb644693aea293523fdd4e0e18f6e48f52563652", "md5": "171183574353643ddda46696efb4f963", "props": { ... } }, ... ]After (Limited fields only):
[ { "path": "npm-remote-cache/.npm/send/package.json", "props": { "artifactory.internal.etag": [ "W/\"171183574353643ddda46696efb4f963\"" ] } }, { "path": "npm-remote-cache/.npm/jfrog-midgard/package.json", "props": { "artifactory.internal.etag": [ "W/\"e247404ece26afdc9cae84ae25ee6f51\"" ] } } ]Verification of Workaround (No Spec File)
Command:
Response (Already working correctly):
[ { "path": "npm-remote-cache/.npm/send/package.json", "props": { "artifactory.internal.etag": [ "W/\"171183574353643ddda46696efb4f963\"" ] } }, { "path": "npm-remote-cache/.npm/jfrog-midgard/package.json", "props": { "artifactory.internal.etag": [ "W/\"e247404ece26afdc9cae84ae25ee6f51\"" ] } } ]Related PRs: