Skip to content

Still gets a comment for a non-existent project when --silence-no-projects flag is used #3192

@raymondchen625

Description

@raymondchen625

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Overview of the Issue

Setting ATLANTIS_SILENCE_NO_PROJECTS=true still gets a no project... comment from atlantis.

Reproduction Steps

My atlantis has environment variable ATLANTIS_SILENCE_NO_PROJECTS=true. When I leave a comment atlantis plan -p non_existent in the PR, I still get a Plan Error comment from atlantis with message no project with name "non_existent" is defined in atlantis.yaml.

Logs

2023-03-06T15:47:42.573Z
no project with name "non_existent" is defined in atlantis.yaml
github.com/runatlantis/atlantis/server/events.(*PullUpdater).updatePull
	github.com/runatlantis/atlantis/server/events/pull_updater.go:17
github.com/runatlantis/atlantis/server/events.(*PlanCommandRunner).run
	github.com/runatlantis/atlantis/server/events/plan_command_runner.go:175
github.com/runatlantis/atlantis/server/events.(*PlanCommandRunner).Run
	github.com/runatlantis/atlantis/server/events/plan_command_runner.go:247
github.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand
	github.com/runatlantis/atlantis/server/events/command_runner.go:296
2023-03-06T15:47:42.096Z
Error building plan commands: no project with name "non_existent" is defined in atlantis.yaml
github.com/runatlantis/atlantis/server/events.(*InstrumentedProjectCommandBuilder).BuildPlanCommands
	github.com/runatlantis/atlantis/server/events/instrumented_project_command_builder.go:69
github.com/runatlantis/atlantis/server/events.(*PlanCommandRunner).run
	github.com/runatlantis/atlantis/server/events/plan_command_runner.go:170
github.com/runatlantis/atlantis/server/events.(*PlanCommandRunner).Run
	github.com/runatlantis/atlantis/server/events/plan_command_runner.go:247
github.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand
	github.com/runatlantis/atlantis/server/events/command_runner.go:296
...

Environment details

Atlantis version: v0.21.0
Atlantis flag:
ATLANTIS_SILENCE_NO_PROJECTS: true

Additional Context

This should be caused by the method PlanCommandRunner.run(), when a returned err!=nil, it always calls the p.pullUpdater.updatePull(ctx, cmd, command.Result{Error: err}) to leave comments in the PR regardless with the cause of the error and the silence-no-projects flag. A quick fix would be similar to this:

		if !(p.SilenceNoProjects && strings.Contains(err.Error(), "no project with name ")) {
			p.pullUpdater.updatePull(ctx, cmd, command.Result{Error: err})
		}

This also happens in a similar location of apply_command_runner.go.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions