Skip to content

Conversation

@WebOfNakedFancies
Copy link

what

  • Modified /api/plan and /api/apply endpoints to run pre-workflow hooks before building commands instead of after
  • Added support for auto-discovery when both Projects and Paths fields are empty in API requests
  • Aligned API execution order with the comment flow architecture to ensure consistent behavior
  • Fixed issue where dynamically generated atlantis.yaml files (via pre-workflow hooks) could not be used with the API

why

  • The API had a critical chicken-and-egg problem: it tried to load atlantis.yaml before pre-workflow hooks could generate it
  • This caused "cannot specify a project name unless an atlantis.yaml file exists" errors for repos using dynamic config generation
  • The API flow was architecturally inconsistent with the comment flow (which runs hooks early and works correctly)
  • Without auto-discovery support, API users couldn't replicate atlantis plan (no args) behavior
  • Repo-level workflow configurations were being ignored when using the API, defaulting to server-defined workflows instead of project-specified ones (e.g., custom terragrunt workflow)

Execution Order Before Fix:
API: Clone → Load Config ❌ → Build Commands → Run Pre-Hooks (too late) Comment: Clone → Run Pre-Hooks ✅ → Load Config → Build Commands

Execution Order After Fix:
API: Clone → Run Pre-Hooks ✅ → Load Config → Build Commands Comment: Clone → Run Pre-Hooks ✅ → Load Config → Build Commands

tests

  • Tested with dynamically generated atlantis.yaml via pre-workflow hooks - config now generates before being read
  • Verified API requests with Projects: ["dev"] properly resolve project configurations and apply repo-level workflows
  • Confirmed auto-discovery works when Projects and Paths are omitted from API request
  • Validated backward compatibility - existing API calls with explicit Projects/Paths continue to work
  • Verified logs show correct workflow merging: "overriding server-defined workflow with repo-specified workflow"

@dosubot dosubot bot added bug Something isn't working go Pull requests that update Go code labels Dec 2, 2025
@github-actions github-actions bot removed the bug Something isn't working label Dec 2, 2025
@WebOfNakedFancies WebOfNakedFancies force-pushed the fix/api-preworkflow-hooks-execution-order branch from f6a540d to 1d290b8 Compare December 2, 2025 15:41
@github-actions github-actions bot added docs Documentation provider/github labels Dec 2, 2025
- Run pre-workflow hooks BEFORE building commands in API flow
- Add support for empty Projects/Paths to trigger auto-discovery
- Align API execution order with comment flow architecture

This fixes dynamic atlantis.yaml generation via pre-workflow hooks
and resolves the chicken-and-egg problem where config was needed
before hooks could generate it.

Signed-off-by: WebOfNakedFancies <[email protected]>
@WebOfNakedFancies WebOfNakedFancies force-pushed the fix/api-preworkflow-hooks-execution-order branch from dd5bd94 to f3d8c35 Compare December 2, 2025 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation go Pull requests that update Go code provider/github

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant