Repository navigation
feat(scan): WithMaxComponents and --max-components send max_components on every upload block - #125
Merged
Merged
Conversation
matiasdaloia
force-pushed
the
feat/max-candidates-per-match
branch
from
October 23, 2026 10:29
118cc39 to
eb42b3b
Compare
ComponentLimit holds a positive count or all, and its zero value is unset. ComponentsUpTo, AllComponents and ParseComponentLimit build one. The scan adds the limit as the max_components query parameter to every WFP block, retries included, because the server refuses a session whose blocks disagree. An unset limit adds no query string.
The flag takes a positive integer or all and is validated before anything is fingerprinted or uploaded. An explicitly empty value is an error, an omitted flag sends nothing. README, CLIENT_HELP and CHANGELOG describe the parameter and what the server reports for it.
matiasdaloia
force-pushed
the
feat/max-candidates-per-match
branch
from
October 23, 2026 12:00
eb42b3b to
ff94e3f
Compare
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.
Why
Customers want to choose how many components a scan reports. scanoss.api now takes a
max_componentsquery parameter onPOST /v3/wfp/scan: a base-10 positive integer (leading zeros allowed) or exactlyall. In chunked mode every upload block of a session must carry the same value or the server answers 400. This PR lets SDK and CLI users send it.Server semantics: N is the best N components of the project ranking for full-file matches, plus up to 3 context picks (folder, file alone, origin) labelled in each match's
context. A snippet block gets up to N candidates, and the allowed set widens to at least N.allmeans no limit.Scope
pkg/scanoss:ComponentLimit(zero value = unset),ComponentsUpTo(n),AllComponents(),ParseComponentLimit(s),IsSet(),String(), andWithMaxComponents(l). When set, the parameter is added to every chunk upload of the scan, built withurl.Values.--max-componentsonscanandscan wfp. It is parsed before fingerprinting or uploading, so an invalid value, or an explicitly empty one, fails with no request sent.resultsdoes not take it (it only polls).scanoss.jsonkey, no change tolibscanoss/.Default: unset sends no
max_componentsparameter. Requests are byte-identical to today and the server defaults apply (2 for full-file matches plus the context picks, 1 per snippet block).The scanoss.api server must support the parameter. A server that does not will ignore it.
Blast Radius
Unset callers: none, no query string is added. Users of the new option or flag against a server without support get the server defaults silently.
uploadChunksanduploadChunkare unexported and gained aqueryargument.scanTuninggained acomponentsargument. The branch was rewritten from the earliermax_candidates_per_matchnaming into two commits on main.Verification
go test ./...,go vet ./...andgofmt -l cmd pkgare clean.make lintcould not run locally: the installed golangci-lint is built with go1.25 and the module targets a newer Go.max_components=5and=allon every chunk and an empty query when unset; aParseComponentLimittable (007accepted;0,-1,2.5, empty,3,3,ALL,+3,1e3,0x10, overflow rejected); a 400 on one block fails the scan with the status named; a block that first gets a 503 carries the parameter on the failed attempt and on its retry; CLI tests assert invalid and explicitly empty values error naming the flag with zero requests seen, and valid values reach every upload block, through bothscan wfpandscan <dir>.