jfrog / jfrog-cli

JFrog CLI is a client that provides a simple interface that automates access to the JFrog products.
https://www.jfrog.com/confluence/display/CLI/JFrog+CLI
Apache License 2.0
531 stars 230 forks source link

`jf rt build-append` fails with 404 when looking for a build with ":" in name #1803

Open lmcpare opened 1 year ago

lmcpare commented 1 year ago

Describe the bug

The build-append command fails to process builds that include the ":" character in their name.

The same command succeeds when processing standard build names, i.e. with the ":" character in them.

Current behavior

$ JFROG_CLI_LOG_LEVEL=DEBUG jf rt build-append "pare-test" "0.0.2" "ksdf::full-buildinfo" "2"
18:01:01 [Debug] JFrog CLI version: 2.32.0
18:01:01 [Debug] OS/Arch: linux/amd64
18:01:01 [🔵Info] Running Build Append command...
18:01:01 [Debug] Saving build general details at: /tmp/jfrog/builds/ba4f5e3ece384f1d5aecfefeb3cb68fbda4fccd635442aec4113c5a6dbc9f3b9/partials
18:01:01 [Debug] Usage Report: Sending info...
18:01:01 [Debug] Getting build-info from:  https://jfrog.kaloom.io/artifactory/api/build/ksdf::full-buildinfo/2
18:01:01 [Debug] Sending HTTP GET request to: https://jfrog.kaloom.io/artifactory/api/build/ksdf::full-buildinfo/2
18:01:01 [Debug] Sending HTTP GET request to: https://jfrog.kaloom.io/artifactory/api/system/version
18:01:01 [Debug] Artifactory response: 200 
18:01:01 [Debug] JFrog Artifactory version is: 7.47.12
18:01:01 [Debug] Sending HTTP POST request to: https://jfrog.kaloom.io/artifactory/api/system/usage
18:01:01 [Debug] Build ksdf::full-buildinfo/2. Started: 2023-01-11T16:30:43.541-0500. Calculated timestamp: 1673472643541
18:01:01 [Debug] Sending HTTP HEAD request to: https://jfrog.kaloom.io/artifactory/artifactory-build-info/ksdf::full-buildinfo/2-1673472643541.json
18:01:01 [Debug] Usage Report: Artifactory response: 200 
18:01:01 [Debug] Usage Report: Usage info sent successfully.
18:01:01 [🚨Error] server response: 404

These are the associated logs in artifactory-request.log:

2023-01-11T23:01:01.455Z|75bf6d7451c06a03|10.128.0.2|pare|GET|/api/system/version|200|-1|0|1|jfrog-cli-go/2.32.0
2023-01-11T23:01:01.458Z|36bf355973f40150|10.128.0.2|pare|GET|/api/build/ksdf::full-buildinfo/2|200|-1|0|3|jfrog-cli-go/2.32.0
2023-01-11T23:01:01.464Z|420bf3aa9e3e8d48|10.128.0.2|pare|POST|/api/system/usage|200|80|0|0|jfrog-cli-go/2.32.0
2023-01-11T23:01:01.474Z|c022b6be5fb9d90d|10.128.0.2|pare|HEAD|/artifactory-build-info/ksdf::full-buildinfo/2-1673472643541.json|404|-1|0|1|jfrog-cli-go/2.32.0

Reproduction steps

Using the build-append command, append the buildInfo of an existing build whose name include a ":" character in it.

Repeat the same command with a regular build name succeeds.

Expected behavior

The build-append command should behave properly for any build name, with or without special chars.

Suggestion: the cli code might need to encode the paths it sends to Artifactory. In the case of build names with special chars, their location within the artifactory-build-info is encoded, where : is replaced by %3A internally in the repo. It may be the reason why the build-append command as it is currently fails.

JFrog CLI version

2.32.0

Operating system type and version

Fedora 36

JFrog Artifactory version

7.47.12

JFrog Xray version

No response

john-heinnickel commented 1 year ago

+1 on this issue

We have the same thing resulting from using default build names on a Jenkins system where the build definitions are kept under folders. Each path separator in the folder hierarchy becomes ' :: ' (a pair of colons with a space on either side) in the build name, and rt ba is the only JFrog CLI command we're using that cannot seem to handle these names.

Same result, a 404 error with no descriptive message

Curiously enough, some of the variations I've tried to look for a workaround print an informative message about the target not being found instead of the more cryptic server response: 404 message. I'll add some sample outputs in case this happens to provide any hints about where the encoding is breaking down

Examples:

// Baseline example, spaces and colons as spaces and colons
$ jf rt ba "csd-genexus- :: dl-installer :: release-0.99.4" "4" "csd-genexus- :: dl-auth-gateway :: release :: 0.99.4" "1"
21:11:50 [🔵Info] Running Build Append command...
21:11:50 [🚨Error] server response: 404 
// Left just the spaces URL-encoded
$ jf rt ba "csd-genexus- :: dl-installer :: release-0.99.4" "4" "csd-genexus-%20::%20dl-auth-gateway%20::%20release%20::%200.99.4" "1"
21:12:14 [🔵Info] Running Build Append command...
21:12:14 [🚨Error] Build csd-genexus-%20::%20dl-auth-gateway%20::%20release%20::%200.99.4/1 not found in Artifactory.
// Sent genuine quotation marks around the name string, appended argument only
root@lemon:~/Git/csd-dl-deployment/builds (git:initial)$ jf rt ba "csd-genexus- :: dl-installer :: release-0.99.4" "4" '"csd-genexus- :: dl-auth-gateway :: release :: 0.99.4"' "1"
21:12:28 [🔵Info] Running Build Append command...
21:12:29 [🚨Error] Build "csd-genexus- :: dl-auth-gateway :: release :: 0.99.4"/1 not found in Artifactory.
// Attempted backslash escaping of spaces
$ jf rt ba "csd-genexus- :: dl-installer :: release-0.99.4" "4" 'csd-genexus-\ ::\ dl-auth-gateway\ ::\ release\ ::\ 0.99.4' "1"
21:12:57 [🔵Info] Running Build Append command...
21:12:57 [🚨Error] server response: 400 
<!doctype html><html lang="en"><head><title>HTTP Status 400 – Bad Request</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 400 – Bad Request</h1></body></html>
// Attempted the conventional replacement of spaces with '+'
$ jf rt ba "csd-genexus- :: dl-installer :: release-0.99.4" "4" "csd-genexus-+::+dl-auth-gateway+::+release+::+0.99.4" "1"
21:13:23 [🔵Info] Running Build Append command...
21:13:24 [🚨Error] Build csd-genexus-+::+dl-auth-gateway+::+release+::+0.99.4/1 not found in Artifactory.
DavidRadoorHummel commented 1 year ago

We have the same issue, though the error is a bit different:

jf rt ba MultiPromoteTest 1 "FB :: ProgDevice2 QA" 897 --server-id=test
11:51:05 [Info] Running Build Append command...
11:51:10 [Error] parsing time "2023-01-08T21:42:40.754+01:00" as "2006-01-02T15:04:05.000-0700": cannot parse "+01:00" as "-0700"

Result is the same though, the append command fails to append the build.

yahavi commented 1 year ago

@lmcpare @john-heinnickel Thanks for reporting this issue. We're currently targeting to handle this issue during Q4. We'll keep you posted.

@DavidRadoorHummel Could you please create another issue with much details as possible such as steps to reproduce and your Artifactory version?


Duplication of https://github.com/jfrog/jfrog-cli/issues/2043

yahavi commented 11 months ago

@lmcpare @DavidRadoorHummel We created https://github.com/jfrog/jfrog-cli-core/pull/1020 to fix this issue. We'll keep you posted.

DavidRadoorHummel commented 11 months ago

Thanks, but we're completely reworking how build info is used in Artifactory. We have use cases where we need build info to have different package protocols in one and be able to promote this. This doesn't work, by default, in Artifactory.

yahavi commented 11 months ago

Sure @DavidRadoorHummel Feel free to contact us if there's anything we can assist with.

DavidRadoorHummel commented 11 months ago

You're already helping immensely by maintaining JFrog CLI 😄 Great tool!

yahavi commented 11 months ago

@lmcpare JFrog CLI 2.51.1 has been released. This version includes the fix for this issue. Feel free to upgrade - we'd appreciate your feedback on that!