8000 Deploy validation fails because of wrong version sorting · Issue #42 · arcxp/deploy-action · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Deploy validation fails because of wrong version sorting #42

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 8000 ”, 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

Open
lbertolami opened this issue May 15, 2025 · 4 comments · May be fixed by #43
Open

Deploy validation fails because of wrong version sorting #42

lbertolami opened this issue May 15, 2025 · 4 comments · May be fixed by #43

Comments

@lbertolami
Copy link

Hi! We found some issues when using the action on different Arc projects. If failed very frequently, however the package was deployed when we accessed Deployer. Upon further investigation we found this:

The root problem seems to be the sort on the getCurrentVersions

const getCurrentVersions = async ({ core, client, apiHostname }) => {
  let responseBody = undefined

  try {
    const url = `https://${apiHostname}/deployments/fusion/services`
    const response = await client.get(url)

    responseBody = await response.readBody()
    const { lambdas } = JSON.parse(responseBody)

    return lambdas.map(({ Version }) => parseInt(Version)).sort()
  } catch (error) {
    if (error.name === 'SyntaxError') {
      return core.setFailed(`Unexpected response from server: ${responseBody}`)
    }
    return core.setFailed(error.message)
  }
}

The javascript sort converts all elements to string for the sorting and makes the order weird in this case. Some examples from activating debug:

Image

In that case, the new version (20) appears in the middle of the array and this condition is never fufiled:

// index.cjs line 87
if (newVersions[newVersions.length - 1] !== latestVersion) {
        newestVersion = newVersions[newVersions.length - 1]
        break
      }

Fix:

We think that adding the correct sorting should fix it as we have tested in our forked version of the action:

return lambdas.map(({ Version }) => parseInt(Version)).sort((a, b) => a - b)

After this change, this is what we see when debugging the step:

Image

@manchicken
Copy link
Contributor

Hey friend. I looked at your issue and I really appreciate you digging in. Can you please try using my test branch maintenance-q2-2025 to make sure that works before I merge it? My testing is working fine, but I don't want to break your setup.

@lbertolami
Copy link
Author

Looks great, here's a run with debug enabled, now the list is sorted as expected:

##[debug]Loading env
Run arcxp/deploy-action@maintenance-q2-2025
##[debug]currentVersions
##[debug]Making call to upload dist/fusion-bundle.zip to https://api......arcpublishing.com/deployments/fusion/bundles
# ...
##[debug]terminateOldestVersionResults
##[debug]New versions: [
##[debug]  8,
##[debug]  9,
##[debug]  19,
##[debug]  20,
##[debug]  21,
##[debug]  22,
##[debug]  23,
##[debug]  24,
##[debug]  25
##[debug]]
##[debug]New versions: [
##[debug]  9,
##[debug]  19,
##[debug]  20,
##[debug]  21,
##[debug]  22,
##[debug]  23,
##[debug]  24,
##[debug]  25
##[debug]]
##[debug]New versions: [
##[debug]  9,
##[debug]  19,
##[debug]  20,
##[debug]  21,
##[debug]  22,
##[debug]  23,
##[debug]  24,
##[debug]  25
##[debug]]
##[debug]New versions: [
##[debug]  9,
##[debug]  19,
##[debug]  20,
##[debug]  21,
##[debug]  22,
##[debug]  23,
##[debug]  24,
##[debug]  25
##[debug]]
##[debug]New versions: [
##[debug]  9,
##[debug]  19,
##[debug]  20,
##[debug]  21,
##[debug]  22,
##[debug]  23,
##[debug]  24,
##[debug]  25
##[debug]]
##[debug]New versions: [
##[debug]  9,
##[debug]  19,
##[debug]  20,
##[debug]  21,
##[debug]  22,
##[debug]  23,
##[debug]  24,
##[debug]  25
##[debug]]
##[debug]New versions: [
##[debug]  9,
##[debug]  19,
##[debug]  20,
##[debug]  21,
##[debug]  22,
##[debug]  23,
##[debug]  24,
##[debug]  25,
##[debug]  26
##[debug]]
##[debug]Finished.
##[debug]Node Action run completed with exit code 0
##[debug]Finishing: Perform the deploy

@manchicken
Copy link
Contributor

Cool. If you'd like to use this for a little bit, I would like to see if you're good on it for a little while before merging.

If you could reply on Monday next week letting me know that all's still well, I can merge this change.

@manchicken manchicken linked a pull request May 29, 2025 that will close this issue
@lbertolami
Copy link
Author

Cool. If you'd like to use this for a little bit, I would like to see if you're good on it for a little while before merging.

If you could reply on Monday next week letting me know that all's still well, I can merge this change.

I'll let you know on Monday for sure! Thanks for taking care of it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0