Skip to content

Conversation

@chrisghill
Copy link
Member

@chrisghill chrisghill commented Dec 10, 2025

This PR adds graceful error handling for schema generation failures in the airlock integration. The changes ensure that when schema parsing fails (e.g., due to invalid configuration files), the application returns informative errors rather than panicking or producing unexpected behavior.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds graceful error handling for schema generation failures in the airlock integration. The changes ensure that when schema parsing fails (e.g., due to invalid configuration files), the application returns informative errors rather than panicking or producing unexpected behavior.

Key changes:

  • Added nil schema checks in provisioners (OpenTofu and Bicep) with diagnostic error messages
  • Modified bundle creation to gracefully handle params import failures
  • Added test coverage for invalid schema scenarios in OpenTofu provisioner

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pkg/provisioners/testdata/opentofu/invalid.tf Adds test fixture with invalid OpenTofu syntax to trigger schema parsing failures
pkg/provisioners/opentofu_test.go Adds test case and error handling assertions for invalid schema scenarios
pkg/provisioners/opentofu.go Adds nil schema check with diagnostic error message in ExportMassdriverInputs
pkg/provisioners/bicep.go Adds nil schema check with diagnostic error message in ExportMassdriverInputs
pkg/params/params.go Adds nil schema check with user-friendly error message for params import
cmd/bundle.go Changes error handling to treat params import failures as non-fatal, allowing bundle creation to continue
Comments suppressed due to low confidence (1)

pkg/provisioners/opentofu_test.go:118

  • The test validation logic for error cases is incomplete. When an error is expected (like in the "invalid" test case), the test should skip file validation and return early. Currently, if an error occurs, the test will still attempt to validate the file at line 104-118, which may cause misleading test failures. Consider adding a return statement or continue after the error validation block at line 102 when tc.errString is not empty.
			expectedFilepath := path.Join(testDir, "_massdriver_variables.tf")
			if len(tc.want) > 0 {
				got, readErr := os.ReadFile(expectedFilepath)
				if readErr != nil {
					t.Fatalf("%d, unexpected error", readErr)
				}

				if string(got) != tc.want {
					t.Errorf("got %s want %s", got, tc.want)
				}
			} else {
				if _, statErr := os.Stat(expectedFilepath); !errors.Is(statErr, os.ErrNotExist) {
					t.Fatalf("file exists when it shouldn't")
				}
			}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@chrisghill chrisghill merged commit f5ebdbd into main Dec 10, 2025
3 of 4 checks passed
@chrisghill chrisghill deleted the patch/gracefully-handle-airlock-import-failures branch December 10, 2025 21:35
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 this pull request may close these issues.

3 participants