Skip to content
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

getArtifactsParser regex is limited to terminal character line width #284

Open
ccano2011 opened this issue Nov 14, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@ccano2011
Copy link

ccano2011 commented Nov 14, 2024

Describe the bug

RegExp: regexp.MustCompile(`^.+\s([^ \t]+)\s+\([\d.]+\s+[A-Za-z]{2}\)`),

This particular regex evaluation only works if it is less than 80 characters in length.

func getArtifactsParser(artifactsPaths *[]string) (parser *gofrogcmd.CmdOutputPattern) {
	return &gofrogcmd.CmdOutputPattern{
		// Regexp to catch the paths in lines such as "INFO     dist/jfrog_python_example-1.0-py3-none-any.whl (1.6 KB)"
		// First part ".+\s" is the line prefix.
		// Second part "([^ \t]+)" is the artifact path as a group.
		// Third part "\s+\([\d.]+\s+[A-Za-z]{2}\)" is the size and unit, surrounded by parentheses.
		RegExp: regexp.MustCompile(`^.+\s([^ \t]+)\s+\([\d.]+\s+[A-Za-z]{2}\)`),
		ExecFunc: func(pattern *gofrogcmd.CmdOutputPattern) (string, error) {
			// Check for out of bound results.
			if len(pattern.MatchedResults)-1 <= 0 {
				log.Debug(fmt.Sprintf("Failed extracting artifact name from line: %s", pattern.Line))
				return pattern.Line, nil
			}
			*artifactsPaths = append(*artifactsPaths, pattern.MatchedResults[1])
			return pattern.Line, nil
		},
	}
}

Current behavior

testrepository_pypitest-2.0.0.dev0+pr.17.br.test.in.artifactorydev.rc.6.tar.gz
INFO     Response from                                                          
         https://artifactorydev.company.com/artifactory/api/pypi/pypi-prod:   
         200                                                                    
18:54:50 [Info] Trace ID for JFrog Platform logs: bb3cd2e5d9d9f926
Error: 0 [Error] open /__w/TestRepository/TestRepository/**actorydev.rc.6-py3-none-any.whl**: no such file or directory

Twine can handle this upload just fine

Reproduction steps

using twine upload pypitest/dist/*
works

using jf twine upload pypitest/dist/* --build-name MyBuild --build-number 123
yields the Error: 0 [Error] open /__w/TestRepository/TestRepository/**actorydev.rc.6-py3-none-any.whl**: no such file or directory

Expected behavior

I would expect that the terminal length be accounted for when using the regex to evaluate the file name.

Operating system type and version

RHEL 8.10; jfcli 2.71.3

@ccano2011 ccano2011 added the bug Something isn't working label Nov 14, 2024
@ccano2011 ccano2011 changed the title getArtifactsParser regex is limited to GoLang Term length getArtifactsParser regex is limited to terminal character line width Nov 14, 2024
@ccano2011
Copy link
Author

@EyalDelarea @eyalbe4 Could you take a look at this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant