runatlantis / atlantis

Terraform Pull Request Automation
https://www.runatlantis.io
Other
7.82k stars 1.06k forks source link

github status context character limit 255 #2506

Open bob-rohan opened 2 years ago

bob-rohan commented 2 years ago

Community Note

Overview of the Issue

Atlantis fails to report status to Github Pull request

Reproduction Steps

As this is character limit I suspect root cause will be in long directory name. As I'm unsure on the comonents of the status message I need some advice from the runatlantis team on this question please.

Logs

Sep 07 16:14:13 ip-10-168-199-68 bash[5613]: {"level":"error","ts":"2022-09-07T16:14:13.324Z","caller":"vcs/instrumented_client.go:203","msg":"Unable to update status at url: https://<REDACT>/jobs/7aae3453-d509-448a-8ca2-fe970f645c36, error: POST https://<REDACT>api/v3/repos/<REDACT>/statuses/dada198778bb3621dd9c4663cbf4289bc3a240c3: 422 Validation Failed [{Resource:Status Field:context Code:custom Message:context is too long (maximum is 255 characters)}]","json":{"repository":"<REDACT>","pull-num":"983"},"stacktrace":"github.com/runatlantis/atlantis/server/events/vcs.(*InstrumentedClient).UpdateStatus\n\t/home/runner/work/atlantis/atlantis/server/events/vcs/instrumented_client.go:203\ngithub.com/runatlantis/atlantis/server/events/vcs.(*ClientProxy).UpdateStatus\n\t/home/runner/work/atlantis/atlantis/server/events/vcs/proxy.go:76\ngithub.com/runatlantis/atlantis/server/events.(*DefaultCommitStatusUpdater).UpdateProject\n\t/home/runner/work/atlantis/atlantis/server/events/commit_status_updater.go:96\ngithub.com/runatlantis/atlantis/server/jobs.(*JobURLSetter).SetJobURLWithStatus\n\t/home/runner/work/atlantis/atlantis/server/jobs/job_url_setter.go:41\ngithub.com/runatlantis/atlantis/server/events.(*ProjectOutputWrapper).updateProjectPRStatus\n\t/home/runner/work/atlantis/atlantis/server/events/project_command_runner.go:164\ngithub.com/runatlantis/atlantis/server/events.(*ProjectOutputWrapper).Plan\n\t/home/runner/work/atlantis/atlantis/server/events/project_command_runner.go:149\ngithub.com/runatlantis/atlantis/server/events.RunAndEmitStats\n\t/home/runner/work/atlantis/atlantis/server/events/instrumented_project_command_runner.go:39\ngithub.com/runatlantis/atlantis/server/events.(*InstrumentedProjectCommandRunner).Plan\n\t/home/runner/work/atlantis/atlantis/server/events/instrumented_project_command_runner.go:13\ngithub.com/runatlantis/atlantis/server/events.runProjectCmdsParallel.func1\n\t/home/runner/work/atlantis/atlantis/server/events/project_command_pool_executor.go:28"}
Sep 07 16:14:13 ip-10-168-199-68 bash[5613]: {"level":"error","ts":"2022-09-07T16:14:13.324Z","caller":"events/project_command_runner.go:165","msg":"updating project PR status%!(EXTRA *github.ErrorResponse=POST https://<REDACT>/api/v3/repos/<REDACT>/statuses/dada198778bb3621dd9c4663cbf4289bc3a240c3: 422 Validation Failed [{Resource:Status Field:context Code:custom Message:context is too long (maximum is 255 characters)}])","json":{"repo":"<REDACT>","pull":"983"},"stacktrace":"github.com/runatlantis/atlantis/server/events.(*ProjectOutputWrapper).updateProjectPRStatus\n\t/home/runner/work/atlantis/atlantis/server/events/project_command_runner.go:165\ngithub.com/runatlantis/atlantis/server/events.(*ProjectOutputWrapper).Plan\n\t/home/runner/work/atlantis/atlantis/server/events/project_command_runner.go:149\ngithub.com/runatlantis/atlantis/server/events.RunAndEmitStats\n\t/home/runner/work/atlantis/atlantis/server/events/instrumented_project_command_runner.go:39\ngithub.com/runatlantis/atlantis/server/events.(*InstrumentedProjectCommandRunner).Plan\n\t/home/runner/work/atlantis/atlantis/server/events/instrumented_project_command_runner.go:13\ngithub.com/runatlantis/atlantis/server/events.runProjectCmdsParallel.func1\n\t/home/runner/work/atlantis/atlantis/server/events/project_command_pool_executor.go:28"}

Environment details

Atlantis server-side config file:

repos:
- id: "/.*/"
  allowed_overrides: [workflow]
  pre_workflow_hooks:
    - run: tac_wrapper # terragrunt-atlantis-config generate --output atlantis.yaml --autoplan --parallel --create-workspace
  post_workflow_hooks:
    - run: rm atlantis.yaml || true
  workflow: terragrunt
  apply_requirements: [mergeable, approved]
workflows:
  terragrunt:
    plan:
      steps:
      - run: terragrunt plan -no-color -out=$PLANFILE
      - run: terragrunt show -json $PLANFILE > $SHOWFILE
    apply:
      steps:
      - run: terragrunt apply -no-color $PLANFILE

Repo atlantis.yaml file:

See tac_wrapper pre_workflow_hooks above

Additional Context

.

bob-rohan commented 2 years ago

Found some old PRs with context defined as atlantis/apply: <path>/<workspace>

Therefore where the workspace is the same as path, the path limit is 119 characters.