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

fix(bitbucketcloud): Ensure status key has at most 40 characters #2037

Conversation

maxbrunet
Copy link
Contributor

@maxbrunet maxbrunet commented Feb 1, 2022

I observed this error:

{
  "level": "error",
  "ts": "2022-02-01T20:21:06.571Z",
  "caller": "events/project_command_runner.go:156",
  "msg": "updating project PR status%!(EXTRA *errors.errorString=making request \"POST https://api.bitbucket.org/2.0/repositories/myworkspace/myrepo/commit/abc1605a840c/statuses/build\" unexpected status code: 400, body: {\"type\": \"error\", \"error\": {\"fields\": {\"key\": [\"Ensure this value has at most 40 characters (it has 53).\"]}, \"message\": \"key: Ensure this value has at most 40 characters (it has 53).\"}})",
  "json": {
    "repo": "myworkspace/myrepo",
    "pull": "19"
  },
  "stacktrace": "github.com/runatlantis/atlantis/server/events.(*ProjectOutputWrapper).updateProjectPRStatus\n\tgithub.com/runatlantis/atlantis/server/events/project_command_runner.go:156\ngithub.com/runatlantis/atlantis/server/events.(*ProjectOutputWrapper).Apply\n\tgithub.com/runatlantis/atlantis/server/events/project_command_runner.go:133\ngithub.com/runatlantis/atlantis/server/events.runProjectCmds\n\tgithub.com/runatlantis/atlantis/server/events/project_command_pool_executor.go:47\ngithub.com/runatlantis/atlantis/server/events.(*ApplyCommandRunner).Run\n\tgithub.com/runatlantis/atlantis/server/events/apply_command_runner.go:146\ngithub.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand\n\tgithub.com/runatlantis/atlantis/server/events/command_runner.go:252"
}

It may not be the fanciest way to truncate a string and add an ellipsis (e.g. slicing bytes vs runes issue...), but it should be enough for most cases here (if not we can always improve later imo)

@maxbrunet maxbrunet requested a review from a team as a code owner February 1, 2022 21:19
@maxbrunet maxbrunet force-pushed the fix/bitbucketcloud/update-status-key-too-long branch from 6132539 to c024330 Compare February 1, 2022 21:49
@maxbrunet maxbrunet force-pushed the fix/bitbucketcloud/update-status-key-too-long branch from c024330 to 0d0458f Compare February 1, 2022 21:59
@chenrui333
Copy link
Member

Thanks @maxbrunet!!

@chenrui333 chenrui333 merged commit f9a41c9 into runatlantis:master Mar 7, 2022
@chenrui333 chenrui333 added this to the v0.19.1 milestone Mar 7, 2022
krrrr38 pushed a commit to krrrr38/atlantis that referenced this pull request Dec 16, 2022
…atlantis#2037)

* fix(bitbucketcloud): Ensure status key has at most 40 characters

* Use fmt.Sprintf()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants