Skip to content

🧪 crane validate offline mode : Automate test for malformed API surface file handling#592

Merged
nachandr merged 4 commits into
migtools:mainfrom
nachandr:860_offline_malformed_json
Jul 3, 2026
Merged

🧪 crane validate offline mode : Automate test for malformed API surface file handling#592
nachandr merged 4 commits into
migtools:mainfrom
nachandr:860_offline_malformed_json

Conversation

@nachandr

@nachandr nachandr commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Fixes #380

  • Tests
    • Added tier1 end-to-end coverage for [MTA-860] offline validation when the API surface input file contains malformed or mis-shaped JSON..
    • Confirms no validation report is produced for malformed inputs.

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a tier1 Ginkgo e2e test for offline crane validation against malformed API surface JSON. It prepares a migration scenario, runs export/transform/apply, then validates eight malformed inputs and checks for failures without generating report.json.

Changes

MTA-860 e2e test

Layer / File(s) Summary
Test scaffolding and pipeline setup
e2e-tests/tests/tier1/mta_860_validate_malformed_api_surface_test.go
Adds imports, sets up the migration scenario with non-admin context skip checks, grants namespace-admin permissions with deferred cleanup, and runs crane export/transform/apply.
Malformed input cases
e2e-tests/tests/tier1/mta_860_validate_malformed_api_surface_test.go
Defines the malformed APIResourcesFile payload cases and their expected error substrings.
Per-case validation checks
e2e-tests/tests/tier1/mta_860_validate_malformed_api_surface_test.go
Writes each malformed payload, runs runner.Validate, checks for errors and missing report.json, and logs completion.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related PRs

  • migtools/crane#491: Both PRs add offline crane validate e2e coverage using exported API-surface data and runner.Validate.
  • migtools/crane#512: Both PRs add Ginkgo offline-validation coverage around APIResourcesFile handling and validation outcomes.

Suggested reviewers: stillalearner, aufi

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The added tier1 e2e test covers malformed API surface JSON handling in offline mode, matching issue #380.
Out of Scope Changes check ✅ Passed The change appears scoped to the requested malformed API surface offline validation test only.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding offline-mode validation tests for malformed API surface handling.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

Test Coverage Report

Total: 47.8%

Per-package coverage

  • github.com/konveyor/crane — 0.0%
  • github.com/konveyor/crane/cmd/apply — 52.7%
  • github.com/konveyor/crane/cmd/convert — 0.0%
  • github.com/konveyor/crane/cmd/export — 92.9%
  • github.com/konveyor/crane/cmd/plugin-manager — 0.0%
  • github.com/konveyor/crane/cmd/plugin-manager/add — 0.0%
  • github.com/konveyor/crane/cmd/plugin-manager/list — 0.0%
  • github.com/konveyor/crane/cmd/plugin-manager/remove — 0.0%
  • github.com/konveyor/crane/cmd/skopeo-sync-gen — 0.0%
  • github.com/konveyor/crane/cmd/transfer-pvc — 9.2%
  • github.com/konveyor/crane/cmd/transform — 59.7%
  • github.com/konveyor/crane/cmd/transform/listplugins — 23.0%
  • github.com/konveyor/crane/cmd/transform/optionals — 0.0%
  • github.com/konveyor/crane/cmd/tunnel-api — 0.0%
  • github.com/konveyor/crane/cmd/validate — 69.2%
  • github.com/konveyor/crane/cmd/version — 20.0%
  • github.com/konveyor/crane/internal/apply — 33.8%
  • github.com/konveyor/crane/internal/buildinfo — 100.0%
  • github.com/konveyor/crane/internal/file — 79.0%
  • github.com/konveyor/crane/internal/flags — 0.0%
  • github.com/konveyor/crane/internal/kustomize — 85.7%
  • github.com/konveyor/crane/internal/plugin — 32.9%
  • github.com/konveyor/crane/internal/transform — 80.9%
  • github.com/konveyor/crane/internal/validate — 58.6%
Full function-level details
github.com/konveyor/crane/cmd/apply/apply.go:44:			Complete								100.0%
github.com/konveyor/crane/cmd/apply/apply.go:50:			Validate								87.5%
github.com/konveyor/crane/cmd/apply/apply.go:64:			Run									0.0%
github.com/konveyor/crane/cmd/apply/apply.go:68:			NewApplyCommand								0.0%
github.com/konveyor/crane/cmd/apply/apply.go:110:			getStageNames								100.0%
github.com/konveyor/crane/cmd/apply/apply.go:118:			addFlagsForOptions							0.0%
github.com/konveyor/crane/cmd/apply/apply.go:134:			run									81.4%
github.com/konveyor/crane/cmd/convert/convert.go:30:			NewConvertOptions							0.0%
github.com/konveyor/crane/cmd/convert/convert.go:63:			addFlagsForConvertOptions						0.0%
github.com/konveyor/crane/cmd/convert/convert.go:74:			Complete								0.0%
github.com/konveyor/crane/cmd/convert/convert.go:83:			Run									0.0%
github.com/konveyor/crane/cmd/convert/convert.go:87:			run									0.0%
github.com/konveyor/crane/cmd/convert/convert.go:112:			getClientFromContext							0.0%
github.com/konveyor/crane/cmd/convert/convert.go:134:			getRestConfigFromContext						0.0%
github.com/konveyor/crane/cmd/export/cluster.go:29:			NewClusterScopeHandler							100.0%
github.com/konveyor/crane/cmd/export/cluster.go:35:			isClusterScopedResource							100.0%
github.com/konveyor/crane/cmd/export/cluster.go:44:			filterRbacResources							100.0%
github.com/konveyor/crane/cmd/export/cluster.go:102:			NewClusterScopedRbacHandler						100.0%
github.com/konveyor/crane/cmd/export/cluster.go:113:			exportedSANamespaces							100.0%
github.com/konveyor/crane/cmd/export/cluster.go:126:			groupMatchesExportedSANamespaces					100.0%
github.com/konveyor/crane/cmd/export/cluster.go:143:			parseServiceAccountUserSubject						100.0%
github.com/konveyor/crane/cmd/export/cluster.go:154:			prepareForFiltering							100.0%
github.com/konveyor/crane/cmd/export/cluster.go:187:			filteredResourcesOfKind							100.0%
github.com/konveyor/crane/cmd/export/cluster.go:213:			accept									100.0%
github.com/konveyor/crane/cmd/export/cluster.go:223:			acceptClusterRoleBinding						100.0%
github.com/konveyor/crane/cmd/export/cluster.go:260:			acceptClusterRole							100.0%
github.com/konveyor/crane/cmd/export/cluster.go:284:			acceptSecurityContextConstraints					100.0%
github.com/konveyor/crane/cmd/export/cluster.go:336:			anyServiceAccountInNamespace						100.0%
github.com/konveyor/crane/cmd/export/crd.go:18:				normalizeGroupSet							85.7%
github.com/konveyor/crane/cmd/export/crd.go:30:				shouldSkipCRDGroup							100.0%
github.com/konveyor/crane/cmd/export/crd.go:51:				crdFailureAPIResourceName						100.0%
github.com/konveyor/crane/cmd/export/crd.go:57:				getOperatorManager							92.9%
github.com/konveyor/crane/cmd/export/crd.go:89:				collectRelatedCRDs							94.7%
github.com/konveyor/crane/cmd/export/discover.go:41:			hasClusterScopedManifests						100.0%
github.com/konveyor/crane/cmd/export/discover.go:59:			prepareClusterResourceDir						100.0%
github.com/konveyor/crane/cmd/export/discover.go:75:			prepareFailuresDir							100.0%
github.com/konveyor/crane/cmd/export/discover.go:87:			writeResources								85.7%
github.com/konveyor/crane/cmd/export/discover.go:135:			writeErrors								83.3%
github.com/konveyor/crane/cmd/export/discover.go:177:			getFilePath								95.2%
github.com/konveyor/crane/cmd/export/discover.go:215:			discoverPreferredResources						100.0%
github.com/konveyor/crane/cmd/export/discover.go:244:			resourceToExtract							100.0%
github.com/konveyor/crane/cmd/export/discover.go:318:			isAdmittedResource							100.0%
github.com/konveyor/crane/cmd/export/discover.go:327:			getObjects								96.3%
github.com/konveyor/crane/cmd/export/discover.go:378:			iterateItemsByGet							90.5%
github.com/konveyor/crane/cmd/export/discover.go:413:			iterateItemsInList							92.3%
github.com/konveyor/crane/cmd/export/export.go:54:			Complete								92.0%
github.com/konveyor/crane/cmd/export/export.go:101:			Validate								100.0%
github.com/konveyor/crane/cmd/export/export.go:142:			validateExportNamespace							87.5%
github.com/konveyor/crane/cmd/export/export.go:159:			allResourceListsForbidden						87.5%
github.com/konveyor/crane/cmd/export/export.go:177:			mergeImpersonationExtras						100.0%
github.com/konveyor/crane/cmd/export/export.go:192:			Run									0.0%
github.com/konveyor/crane/cmd/export/export.go:316:			NewExportCommand							48.1%
github.com/konveyor/crane/cmd/plugin-manager/add/add.go:43:		Complete								0.0%
github.com/konveyor/crane/cmd/plugin-manager/add/add.go:48:		Validate								0.0%
github.com/konveyor/crane/cmd/plugin-manager/add/add.go:91:		Run									0.0%
github.com/konveyor/crane/cmd/plugin-manager/add/add.go:95:		NewAddCommand								0.0%
github.com/konveyor/crane/cmd/plugin-manager/add/add.go:127:		addFlagsForOptions							0.0%
github.com/konveyor/crane/cmd/plugin-manager/add/add.go:132:		run									0.0%
github.com/konveyor/crane/cmd/plugin-manager/add/add.go:204:		downloadBinary								0.0%
github.com/konveyor/crane/cmd/plugin-manager/add/add.go:253:		binaryURIForPlatform							0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:46:		Complete								0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:51:		Validate								0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:56:		Run									0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:60:		NewListCommand								0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:90:		addFlagsForOptions							0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:98:		run									0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:167:		printInstalledInformation						0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:177:		groupInformationForPlugins						0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:196:		printInformation							0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:208:		printParamsInformation							0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:222:		getOptionalFields							0.0%
github.com/konveyor/crane/cmd/plugin-manager/list/list.go:247:		printTable								0.0%
github.com/konveyor/crane/cmd/plugin-manager/plugin-manager.go:33:	Complete								0.0%
github.com/konveyor/crane/cmd/plugin-manager/plugin-manager.go:38:	Validate								0.0%
github.com/konveyor/crane/cmd/plugin-manager/plugin-manager.go:43:	Run									0.0%
github.com/konveyor/crane/cmd/plugin-manager/plugin-manager.go:47:	NewPluginManagerCommand							0.0%
github.com/konveyor/crane/cmd/plugin-manager/plugin-manager.go:78:	addFlagsForOptions							0.0%
github.com/konveyor/crane/cmd/plugin-manager/plugin-manager.go:86:	run									0.0%
github.com/konveyor/crane/cmd/plugin-manager/remove/remove.go:33:	Complete								0.0%
github.com/konveyor/crane/cmd/plugin-manager/remove/remove.go:38:	Validate								0.0%
github.com/konveyor/crane/cmd/plugin-manager/remove/remove.go:43:	Run									0.0%
github.com/konveyor/crane/cmd/plugin-manager/remove/remove.go:47:	NewRemoveCommand							0.0%
github.com/konveyor/crane/cmd/plugin-manager/remove/remove.go:77:	run									0.0%
github.com/konveyor/crane/cmd/skopeo-sync-gen/skopeo-sync-gen.go:61:	Complete								0.0%
github.com/konveyor/crane/cmd/skopeo-sync-gen/skopeo-sync-gen.go:65:	Validate								0.0%
github.com/konveyor/crane/cmd/skopeo-sync-gen/skopeo-sync-gen.go:69:	NewSkopeoSyncGenCommand							0.0%
github.com/konveyor/crane/cmd/skopeo-sync-gen/skopeo-sync-gen.go:103:	shouldAddImageStream							0.0%
github.com/konveyor/crane/cmd/skopeo-sync-gen/skopeo-sync-gen.go:114:	Run									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:37:		NewRsyncLogStream							0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:50:		Init									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:138:		writeProgressToFile							0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:148:		Close									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:154:		Streams									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:190:		addDataSize								0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:215:		String									100.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:219:		MarshalJSON								0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:223:		AsString								0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:271:		NewProgress								100.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:291:		Completed								0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:296:		Status									38.5%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:321:		Merge									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:376:		newDataSize								72.7%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:399:		parseRsyncLogs								76.1%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:479:		waitForPodRunning							0.0%
github.com/konveyor/crane/cmd/transfer-pvc/progress.go:513:		getFinalPodStatus							0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:89:		Validate								0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:117:		Validate								0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:133:		NewTransferPVCCommand							0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:169:		addFlagsToTransferPVCCommand						0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:189:		Complete								0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:220:		Validate								0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:246:		Run									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:250:		getClientFromContext							0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:271:		getRestConfigFromContext						0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:278:		run									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:485:		getValidatedResourceName						0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:495:		getNodeNameForPVC							0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:515:		getIDsForNamespace							0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:541:		getRsyncClientPodSecurityContext					0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:553:		getRsyncServerPodSecurityContext					0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:565:		garbageCollect								0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:602:		deleteResourcesIteratively						0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:628:		deleteResourcesForGVK							0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:649:		followClientLogs							0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:678:		waitForEndpoint								0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:690:		createEndpoint								0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:735:		getRouteHostName							0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:752:		buildDestinationPVC							0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:773:		ApplyTo									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:793:		ApplyTo									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:805:		ApplyTo									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:821:		String									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:825:		Set									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:835:		Type									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:841:		parseSourceDestinationMapping						100.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:863:		String									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:867:		Set									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:876:		Type									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:880:		String									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:884:		Set									0.0%
github.com/konveyor/crane/cmd/transfer-pvc/transfer-pvc.go:894:		Type									0.0%
github.com/konveyor/crane/cmd/transform/listplugins/listplugins.go:33:	Complete								0.0%
github.com/konveyor/crane/cmd/transform/listplugins/listplugins.go:38:	Validate								0.0%
github.com/konveyor/crane/cmd/transform/listplugins/listplugins.go:43:	Run									0.0%
github.com/konveyor/crane/cmd/transform/listplugins/listplugins.go:47:	NewListPluginsCommand							0.0%
github.com/konveyor/crane/cmd/transform/listplugins/listplugins.go:80:	GetPluginNames								85.7%
github.com/konveyor/crane/cmd/transform/listplugins/listplugins.go:95:	getFilteredPlugins							75.0%
github.com/konveyor/crane/cmd/transform/listplugins/listplugins.go:104:	run									0.0%
github.com/konveyor/crane/cmd/transform/optionals/optionals.go:31:	Complete								0.0%
github.com/konveyor/crane/cmd/transform/optionals/optionals.go:36:	Validate								0.0%
github.com/konveyor/crane/cmd/transform/optionals/optionals.go:41:	Run									0.0%
github.com/konveyor/crane/cmd/transform/optionals/optionals.go:45:	NewOptionalsCommand							0.0%
github.com/konveyor/crane/cmd/transform/optionals/optionals.go:78:	run									0.0%
github.com/konveyor/crane/cmd/transform/transform.go:56:		Complete								0.0%
github.com/konveyor/crane/cmd/transform/transform.go:62:		Validate								83.3%
github.com/konveyor/crane/cmd/transform/transform.go:81:		Run									0.0%
github.com/konveyor/crane/cmd/transform/transform.go:86:		getPluginCompletions							100.0%
github.com/konveyor/crane/cmd/transform/transform.go:111:		NewTransformCommand							0.0%
github.com/konveyor/crane/cmd/transform/transform.go:155:		addFlagsForOptions							0.0%
github.com/konveyor/crane/cmd/transform/transform.go:177:		run									11.8%
github.com/konveyor/crane/cmd/transform/transform.go:328:		optionalFlagsToLower							100.0%
github.com/konveyor/crane/cmd/transform/transform.go:338:		runStageWithCleanup							0.0%
github.com/konveyor/crane/cmd/transform/transform.go:354:		reconcileInstructionStages						81.0%
github.com/konveyor/crane/cmd/transform/transform.go:397:		ensurePreviousStagesRun							83.3%
github.com/konveyor/crane/cmd/transform/transform.go:414:		ensureStagesHaveOutput							92.9%
github.com/konveyor/crane/cmd/transform/transform.go:453:		createDefaultStagesForAllPlugins					94.7%
github.com/konveyor/crane/cmd/transform/transform.go:505:		validateStageNameToken							100.0%
github.com/konveyor/crane/cmd/transform/transform.go:520:		findStageByDirName							100.0%
github.com/konveyor/crane/cmd/transform/transform.go:532:		findStagesByName							100.0%
github.com/konveyor/crane/cmd/transform/transform.go:544:		createStageDirectory							77.8%
github.com/konveyor/crane/cmd/transform/transform.go:565:		createCustomStageWithExplicitName					100.0%
github.com/konveyor/crane/cmd/transform/transform.go:581:		createCustomStageWithAutoPriority					71.4%
github.com/konveyor/crane/cmd/transform/transform.go:603:		createPluginStage							0.0%
github.com/konveyor/crane/cmd/transform/transform.go:636:		resolveAndValidateStages						58.5%
github.com/konveyor/crane/cmd/tunnel-api/tunnel-api.go:35:		NewTunnelAPIOptions							0.0%
github.com/konveyor/crane/cmd/tunnel-api/tunnel-api.go:65:		addFlagsForTunnelAPIOptions						0.0%
github.com/konveyor/crane/cmd/tunnel-api/tunnel-api.go:77:		Complete								0.0%
github.com/konveyor/crane/cmd/tunnel-api/tunnel-api.go:100:		Validate								0.0%
github.com/konveyor/crane/cmd/tunnel-api/tunnel-api.go:116:		Run									0.0%
github.com/konveyor/crane/cmd/tunnel-api/tunnel-api.go:120:		getClientFromContext							0.0%
github.com/konveyor/crane/cmd/tunnel-api/tunnel-api.go:129:		getRestConfigFromContext						0.0%
github.com/konveyor/crane/cmd/tunnel-api/tunnel-api.go:136:		run									0.0%
github.com/konveyor/crane/cmd/validate/validate.go:37:			Complete								90.0%
github.com/konveyor/crane/cmd/validate/validate.go:56:			determineClusterContext							91.7%
github.com/konveyor/crane/cmd/validate/validate.go:84:			Validate								100.0%
github.com/konveyor/crane/cmd/validate/validate.go:129:			Run									16.7%
github.com/konveyor/crane/cmd/validate/validate.go:235:			NewValidateCommand							47.6%
github.com/konveyor/crane/cmd/version/version.go:20:			Complete								0.0%
github.com/konveyor/crane/cmd/version/version.go:25:			Validate								0.0%
github.com/konveyor/crane/cmd/version/version.go:30:			Run									0.0%
github.com/konveyor/crane/cmd/version/version.go:34:			NewVersionCommand							0.0%
github.com/konveyor/crane/cmd/version/version.go:60:			run									100.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:21:			CreateTempDir								100.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:28:			ListFilesRecursively							91.7%
github.com/konveyor/crane/e2e-tests/utils/utils.go:51:			ListFilesRecursivelyAsList						80.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:75:			HasFilesRecursively							80.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:86:			ReadTestdataFile							88.9%
github.com/konveyor/crane/e2e-tests/utils/utils.go:105:			TestdataFilePath							0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:125:			GoldenManifestsDir							90.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:147:			GoldenManifestsDirForPlatform						0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:170:			CompareDirectoryFileSets						78.9%
github.com/konveyor/crane/e2e-tests/utils/utils.go:205:			CompareDirectoryYAMLSemantics						82.4%
github.com/konveyor/crane/e2e-tests/utils/utils.go:239:			CompareDirectoryYAMLSemanticsExport					100.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:247:			CompareDirectoryYAMLSemanticsExportAllowOptionalOCPOutputDefaults	100.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:251:			compareDirectoryYAMLSemanticsExport					92.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:330:			isOptionalOCPOutputIdentity						100.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:357:			buildNormalizedExportIndex						81.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:397:			canonicalizeDocs							87.5%
github.com/konveyor/crane/e2e-tests/utils/utils.go:411:			extractResourceIdentity							79.5%
github.com/konveyor/crane/e2e-tests/utils/utils.go:482:			parseYAMLDocuments							100.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:498:			canonicalOpenShiftDockercfgSecretName					80.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:514:			compareYAMLFileBytes							100.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:541:			AssertNoKindsInOutput							0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:597:			AssertKindsInOutput							0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:649:			LooksLikeYAMLFile							100.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:663:			normalizeUnstableFields							77.8%
github.com/konveyor/crane/e2e-tests/utils/utils.go:741:			stripPodTemplateHash							0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:749:			normalizePodServiceAccountVolumeNames					90.9%
github.com/konveyor/crane/e2e-tests/utils/utils.go:806:			normalizeServiceAccountDockercfgReferences				94.1%
github.com/konveyor/crane/e2e-tests/utils/utils.go:840:			normalizeWithPath							83.3%
github.com/konveyor/crane/e2e-tests/utils/utils.go:878:			shouldDropField								100.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:934:			AssertWhiteoutResourceFilesExist					0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:974:			AssertWhiteoutResourceFileCount						0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:1006:		AssertWhiteoutCommentsInKustomization					0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:1061:		AssertKindsNotInActiveKustomizeResources				0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:1103:		CaptureAPISurfaceScriptPath						75.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:1122:		ToInt64									0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:1139:		ExtractCPUAverageUtilization						0.0%
github.com/konveyor/crane/e2e-tests/utils/utils.go:1172:		AssertFilesExist							0.0%
github.com/konveyor/crane/internal/apply/kustomize.go:31:		ApplySingleStage							0.0%
github.com/konveyor/crane/internal/apply/kustomize.go:80:		ApplyMultiStage								0.0%
github.com/konveyor/crane/internal/apply/kustomize.go:134:		runKustomizeBuild							0.0%
github.com/konveyor/crane/internal/apply/kustomize.go:143:		filterClusterScopedResources						82.4%
github.com/konveyor/crane/internal/apply/kustomize.go:199:		splitMultiDocYAMLToFiles						86.7%
github.com/konveyor/crane/internal/buildinfo/buildinfo.go:25:		readKustomizeVersion							100.0%
github.com/konveyor/crane/internal/file/file_helper.go:22:		ReadFiles								100.0%
github.com/konveyor/crane/internal/file/file_helper.go:32:		readFiles								84.0%
github.com/konveyor/crane/internal/file/file_helper.go:91:		GetWhiteOutFilePath							100.0%
github.com/konveyor/crane/internal/file/file_helper.go:95:		GetTransformPath							100.0%
github.com/konveyor/crane/internal/file/file_helper.go:99:		GetIgnoredPatchesPath							0.0%
github.com/konveyor/crane/internal/file/file_helper.go:103:		updateTransformDirPath							100.0%
github.com/konveyor/crane/internal/file/file_helper.go:107:		updateIgnoredPatchesDirPath						0.0%
github.com/konveyor/crane/internal/file/file_helper.go:114:		updatePath								100.0%
github.com/konveyor/crane/internal/file/file_helper.go:121:		GetOutputFilePath							100.0%
github.com/konveyor/crane/internal/file/file_helper.go:131:		GetStageDir								100.0%
github.com/konveyor/crane/internal/file/file_helper.go:137:		GetInputDir								100.0%
github.com/konveyor/crane/internal/file/file_helper.go:143:		GetPatchesDir								100.0%
github.com/konveyor/crane/internal/file/file_helper.go:149:		GetKustomizationPath							100.0%
github.com/konveyor/crane/internal/file/file_helper.go:155:		GetMetadataPath								100.0%
github.com/konveyor/crane/internal/file/file_helper.go:161:		GetResourceTypeFilePath							100.0%
github.com/konveyor/crane/internal/file/file_helper.go:167:		GetPatchFilePath							100.0%
github.com/konveyor/crane/internal/file/file_helper.go:174:		GetStageTransformDir							0.0%
github.com/konveyor/crane/internal/file/file_helper.go:180:		GetStageOutputDir							0.0%
github.com/konveyor/crane/internal/file/file_helper.go:187:		GetResourceFilename							75.0%
github.com/konveyor/crane/internal/file/ordering.go:82:			GetResourceOrder							100.0%
github.com/konveyor/crane/internal/file/ordering.go:92:			GetOrderedResourceFilename						100.0%
github.com/konveyor/crane/internal/flags/global_flags.go:14:		ApplyFlags								0.0%
github.com/konveyor/crane/internal/flags/global_flags.go:21:		GetLogger								0.0%
github.com/konveyor/crane/internal/flags/global_flags.go:29:		initConfig								0.0%
github.com/konveyor/crane/internal/flags/help_groups.go:12:		KubernetesClientInheritedFlagNames					0.0%
github.com/konveyor/crane/internal/flags/help_groups.go:40:		SetGroupedHelp								0.0%
github.com/konveyor/crane/internal/kustomize/args.go:20:		ParseAndValidateArgs							100.0%
github.com/konveyor/crane/internal/kustomize/args.go:92:		splitArgs								100.0%
github.com/konveyor/crane/internal/kustomize/runner.go:21:		Build									82.4%
github.com/konveyor/crane/internal/kustomize/runner.go:55:		buildOptions								100.0%
github.com/konveyor/crane/internal/kustomize/runner.go:105:		setEnvVars								46.2%
github.com/konveyor/crane/internal/plugin/plugin_helper.go:21:		GetPlugins								0.0%
github.com/konveyor/crane/internal/plugin/plugin_helper.go:38:		getBinaryPlugins							0.0%
github.com/konveyor/crane/internal/plugin/plugin_helper.go:63:		IsExecAny								0.0%
github.com/konveyor/crane/internal/plugin/plugin_helper.go:67:		GetFilteredPlugins							0.0%
github.com/konveyor/crane/internal/plugin/plugin_helper.go:109:		isPluginInList								0.0%
github.com/konveyor/crane/internal/plugin/plugin_manager_helper.go:24:	BuildManifestMap							0.0%
github.com/konveyor/crane/internal/plugin/plugin_manager_helper.go:68:	GetYamlFromUrl								75.0%
github.com/konveyor/crane/internal/plugin/plugin_manager_helper.go:82:	YamlToManifest								72.7%
github.com/konveyor/crane/internal/plugin/plugin_manager_helper.go:104:	FilterPluginForOsArch							100.0%
github.com/konveyor/crane/internal/plugin/plugin_manager_helper.go:119:	GetDefaultSource							0.0%
github.com/konveyor/crane/internal/plugin/plugin_manager_helper.go:128:	LocateBinaryInPluginDir							0.0%
github.com/konveyor/crane/internal/plugin/plugin_manager_helper.go:140:	IsUrl									100.0%
github.com/konveyor/crane/internal/plugin/plugin_manager_helper.go:146:	getData									80.0%
github.com/konveyor/crane/internal/transform/instructions.go:31:	LoadInstructions							61.1%
github.com/konveyor/crane/internal/transform/instructions.go:63:	friendlyInstructionsDecodeError						87.5%
github.com/konveyor/crane/internal/transform/instructions.go:78:	ValidateInstructions							100.0%
github.com/konveyor/crane/internal/transform/instructions.go:112:	GenerateStageDirNames							100.0%
github.com/konveyor/crane/internal/transform/orchestrator.go:41:	RunMultiStage								75.6%
github.com/konveyor/crane/internal/transform/orchestrator.go:142:	executeStage								72.7%
github.com/konveyor/crane/internal/transform/orchestrator.go:194:	transformResources							68.4%
github.com/konveyor/crane/internal/transform/orchestrator.go:245:	formatResourceID							0.0%
github.com/konveyor/crane/internal/transform/orchestrator.go:252:	getPluginForStage							90.9%
github.com/konveyor/crane/internal/transform/orchestrator.go:279:	getAvailablePluginNames							0.0%
github.com/konveyor/crane/internal/transform/orchestrator.go:292:	applyStageTransforms							82.1%
github.com/konveyor/crane/internal/transform/orchestrator.go:359:	loadResourcesFromDirectory						85.7%
github.com/konveyor/crane/internal/transform/orchestrator.go:374:	writeResourcesToDirectory						73.1%
github.com/konveyor/crane/internal/transform/stages.go:22:		DiscoverStages								90.5%
github.com/konveyor/crane/internal/transform/stages.go:83:		FilterStages								100.0%
github.com/konveyor/crane/internal/transform/stages.go:112:		GetFirstStage								100.0%
github.com/konveyor/crane/internal/transform/stages.go:122:		GetLastStage								66.7%
github.com/konveyor/crane/internal/transform/stages.go:132:		GetPreviousStage							100.0%
github.com/konveyor/crane/internal/transform/stages.go:142:		GetNextStage								100.0%
github.com/konveyor/crane/internal/transform/stages.go:152:		ValidateStageName							100.0%
github.com/konveyor/crane/internal/transform/stages.go:161:		GenerateStageName							100.0%
github.com/konveyor/crane/internal/transform/test_helpers.go:8:		hasKustomizeCommand							100.0%
github.com/konveyor/crane/internal/transform/test_helpers.go:14:	contains								100.0%
github.com/konveyor/crane/internal/transform/test_helpers.go:23:	findInString								100.0%
github.com/konveyor/crane/internal/transform/writer.go:28:		NewKustomizeWriter							100.0%
github.com/konveyor/crane/internal/transform/writer.go:37:		WriteStage								68.4%
github.com/konveyor/crane/internal/transform/writer.go:218:		getResourceID								100.0%
github.com/konveyor/crane/internal/transform/writer.go:231:		filterValidRemoveOps							76.2%
github.com/konveyor/crane/internal/transform/writer.go:275:		pathExists								93.5%
github.com/konveyor/crane/internal/transform/writer.go:352:		generateKustomizationWithComments					93.8%
github.com/konveyor/crane/internal/transform/writer.go:383:		checkStageDirectory							23.1%
github.com/konveyor/crane/internal/validate/api_resources.go:24:	ParseAPIResourcesJSON							89.7%
github.com/konveyor/crane/internal/validate/matcher.go:25:		MatchResults								75.0%
github.com/konveyor/crane/internal/validate/matcher.go:36:		MatchResultsFromIndex							100.0%
github.com/konveyor/crane/internal/validate/matcher.go:76:		buildDiscoveryIndex							71.4%
github.com/konveyor/crane/internal/validate/matcher.go:110:		matchEntry								100.0%
github.com/konveyor/crane/internal/validate/matcher.go:139:		buildKindIndex								100.0%
github.com/konveyor/crane/internal/validate/matcher.go:151:		addSuggestion								91.7%
github.com/konveyor/crane/internal/validate/report.go:17:		FormatTable								91.3%
github.com/konveyor/crane/internal/validate/report.go:60:		FormatJSON								100.0%
github.com/konveyor/crane/internal/validate/report.go:67:		FormatYAML								0.0%
github.com/konveyor/crane/internal/validate/report.go:79:		WriteFailures								0.0%
github.com/konveyor/crane/internal/validate/report.go:115:		failureFileName								0.0%
github.com/konveyor/crane/internal/validate/report.go:129:		safeFilePart								0.0%
github.com/konveyor/crane/internal/validate/report.go:145:		parseAPIVersion								0.0%
github.com/konveyor/crane/internal/validate/scanner.go:34:		ScanManifests								76.5%
github.com/konveyor/crane/internal/validate/types.go:46:		HasIncompatible								100.0%
github.com/konveyor/crane/internal/validate/types.go:49:		IncompatibleResults							0.0%
github.com/konveyor/crane/main.go:22:					main									0.0%
total:									(statements)								47.8%

Posted by CI

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@e2e-tests/tests/tier1/mta_860_validate_malformed_api_surface_test.go`:
- Around line 93-360: The eight malformed-JSON scenarios in this test are
implemented with repeated write-file, runner.Validate, and error assertions;
refactor them into a table-driven test loop. Use a slice of case structs (for
example with name, content, validateDir suffix, and expected error substrings)
or Ginkgo DescribeTable/Entry around the existing runner.Validate and
ValidateOptions usage, so each scenario only supplies its unique payload and
expectations. Keep the shared setup and assertions in one place and preserve the
per-case checks for report.json absence and substring matching on err.Error().
- Around line 162-192: Test Cases 3 and 6 only log the result and never assert
the expected behavior, so they pass unconditionally. Update the malformed JSON
scenarios around runner.Validate in the tier1 validate test to explicitly define
the intended outcome and add Expect assertions for it, rather than branching on
err and printing logs. Use the existing validation setup in the test cases to
verify either a required error or a required successful report, and make the
assertions consistent with the other cases.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6fe770a1-2cfb-4cca-83c3-883166126133

📥 Commits

Reviewing files that changed from the base of the PR and between a4e7d18 and 13a9f28.

📒 Files selected for processing (1)
  • e2e-tests/tests/tier1/mta_860_validate_malformed_api_surface_test.go

Comment thread e2e-tests/tests/tier1/mta_860_validate_malformed_api_surface_test.go Outdated
Comment thread e2e-tests/tests/tier1/mta_860_validate_malformed_api_surface_test.go Outdated
…rface file handling

Signed-off-by: Nandini Chandra <nachandr@redhat.com>
@nachandr nachandr force-pushed the 860_offline_malformed_json branch from 13a9f28 to 7d249ab Compare July 1, 2026 20:56

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
e2e-tests/tests/tier1/mta_860_validate_malformed_api_surface_test.go (1)

181-218: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Inner loop variable shadows outer i.

for i, substr := range tc.errorSubstrings (line 215) shadows the outer i from line 181. Harmless here since testNum is precomputed, but confusing to read.

♻️ Proposed rename
-				for i, substr := range tc.errorSubstrings {
-					matchers[i] = ContainSubstring(substr)
+				for j, substr := range tc.errorSubstrings {
+					matchers[j] = ContainSubstring(substr)
 				}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e-tests/tests/tier1/mta_860_validate_malformed_api_surface_test.go` around
lines 181 - 218, The inner loop in the malformed API surface test is shadowing
the outer loop index, which makes the validation block harder to read. In
mta_860_validate_malformed_api_surface_test.go, rename the index variable used
in the tc.errorSubstrings range loop inside the test case loop so it does not
reuse the outer loop’s identifier from the same test case iteration. Keep the
behavior the same and update the matcher construction in that block accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@e2e-tests/tests/tier1/mta_860_validate_malformed_api_surface_test.go`:
- Around line 31-36: Remove the empty-context Skip guards in the tier1 malformed
API surface test so RUN_AS_ADMIN can execute the scenario. Update the validation
logic in mta_860_validate_malformed_api_surface_test to stop skipping when
scenario.SrcAppNonAdmin.Context or scenario.TgtAppNonAdmin.Context is empty, and
let the test rely on the admin override path instead.
- Around line 38-57: This test setup is using
SetupNamespaceAdminUsersForScenario, which is flagged by the run-as-admin
compliance check and still leaves the non-admin app contexts empty. Switch to
SetupActiveKubectlRunners to initialize the source and target kubectl runners,
and remove the empty-context skip guards on scenario.SrcAppNonAdmin and
scenario.TgtAppNonAdmin so the RUN_AS_ADMIN override can be applied
consistently.

---

Nitpick comments:
In `@e2e-tests/tests/tier1/mta_860_validate_malformed_api_surface_test.go`:
- Around line 181-218: The inner loop in the malformed API surface test is
shadowing the outer loop index, which makes the validation block harder to read.
In mta_860_validate_malformed_api_surface_test.go, rename the index variable
used in the tc.errorSubstrings range loop inside the test case loop so it does
not reuse the outer loop’s identifier from the same test case iteration. Keep
the behavior the same and update the matcher construction in that block
accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 161d0417-f0c6-4908-b5a4-e6ca5da73db5

📥 Commits

Reviewing files that changed from the base of the PR and between 13a9f28 and 7d249ab.

📒 Files selected for processing (1)
  • e2e-tests/tests/tier1/mta_860_validate_malformed_api_surface_test.go

Comment thread e2e-tests/tests/tier1/mta_860_validate_malformed_api_surface_test.go Outdated
@nachandr nachandr force-pushed the 860_offline_malformed_json branch from 7d249ab to 1a1f191 Compare July 2, 2026 00:50

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
e2e-tests/tests/tier1/mta_860_validate_malformed_api_surface_test.go (2)

207-210: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Inner loop variable shadows outer i.

The for i, substr := range tc.errorSubstrings at Line 208 shadows the outer for i, tc := range testCases variable (line 174). Harmless here since testNum is computed before the shadow, but confusing on read.

♻️ Proposed rename
-				matchers := make([]types.GomegaMatcher, len(tc.errorSubstrings))
-				for i, substr := range tc.errorSubstrings {
-					matchers[i] = ContainSubstring(substr)
-				}
+				matchers := make([]types.GomegaMatcher, len(tc.errorSubstrings))
+				for j, substr := range tc.errorSubstrings {
+					matchers[j] = ContainSubstring(substr)
+				}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e-tests/tests/tier1/mta_860_validate_malformed_api_surface_test.go` around
lines 207 - 210, The inner range variable in the matcher-building loop shadows
the outer test-case index, making the nested loops harder to read. Rename the
inner `i` used in the `for i, substr := range tc.errorSubstrings` loop in
`Test...` to a distinct name like `j` or `idx`, and keep the rest of the matcher
construction unchanged.

199-211: 🎯 Functional Correctness | 🔵 Trivial | ⚖️ Poor tradeoff

Substring assertions are largely tautological for unmarshal-failure cases.

Every case that reaches the json.Unmarshal failure path is wrapped as "parsing api-resources JSON from %q: %w" by ParseAPIResourcesJSON. That wrapper text alone always contains the literal substrings "JSON" and "parsing" (which contains "parse"), so the per-case errorSubstrings lists (e.g., "invalid", "syntax", "EOF", "character") are effectively redundant — the Or(...) matcher will pass via the wrapper text regardless of whether the specific inner error text changes or regresses. Consider asserting on the un-wrapped root error text (e.g., via errors.Unwrap / errors.As) or checking that a case-specific substring is present, to make these assertions actually discriminating.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e-tests/tests/tier1/mta_860_validate_malformed_api_surface_test.go` around
lines 199 - 211, The error-substring check in this test is too weak because
ParseAPIResourcesJSON wraps all json.Unmarshal failures with a generic message,
so the current Or(matchers...) can pass on wrapper text alone. Update the
validation logic around tc.errorSubstrings in this test to inspect the
underlying/root error from err (for example by unwrapping or using errors.As)
and assert on a case-specific substring from that inner error instead of the
wrapper, using the existing tc.errorSubstrings and errMsg/err handling.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@e2e-tests/tests/tier1/mta_860_validate_malformed_api_surface_test.go`:
- Around line 116-124: The "Valid JSON but incorrect structure" case in the
malformed API surface test is asserting the wrong failure path: the fixture in
the ParseAPIResourcesJSON flow is still valid JSON, so it should hit the
empty-list error rather than an unmarshal error. Update this case to either
expect the wrapped "loading api-resources" plus "contains no API resource lists"
message, or change the fileContent in this test case so it actually produces a
JSON parse failure.

---

Nitpick comments:
In `@e2e-tests/tests/tier1/mta_860_validate_malformed_api_surface_test.go`:
- Around line 207-210: The inner range variable in the matcher-building loop
shadows the outer test-case index, making the nested loops harder to read.
Rename the inner `i` used in the `for i, substr := range tc.errorSubstrings`
loop in `Test...` to a distinct name like `j` or `idx`, and keep the rest of the
matcher construction unchanged.
- Around line 199-211: The error-substring check in this test is too weak
because ParseAPIResourcesJSON wraps all json.Unmarshal failures with a generic
message, so the current Or(matchers...) can pass on wrapper text alone. Update
the validation logic around tc.errorSubstrings in this test to inspect the
underlying/root error from err (for example by unwrapping or using errors.As)
and assert on a case-specific substring from that inner error instead of the
wrapper, using the existing tc.errorSubstrings and errMsg/err handling.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e06a44ee-512c-4f96-b852-1879afccc5b0

📥 Commits

Reviewing files that changed from the base of the PR and between 7d249ab and 1a1f191.

📒 Files selected for processing (1)
  • e2e-tests/tests/tier1/mta_860_validate_malformed_api_surface_test.go

…rface file handling

Signed-off-by: Nandini Chandra <nachandr@redhat.com>
@nachandr nachandr force-pushed the 860_offline_malformed_json branch 2 times, most recently from e654706 to ea51f06 Compare July 2, 2026 02:48
…rface file handling

Signed-off-by: Nandini Chandra <nachandr@redhat.com>
@nachandr nachandr force-pushed the 860_offline_malformed_json branch from ea51f06 to 7339fa6 Compare July 2, 2026 04:07
@nachandr

nachandr commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

/ready-for-review

// Verify validation report was not created
reportPath := filepath.Join(validateDir, "report.json")
Expect(reportPath).NotTo(BeAnExistingFile(), "report.json should not be created with malformed JSON")
} else {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @nachandr ,

One small question on test intent: in the current cases, every entry sets expectError: true, so the success branch (else) is never exercised. Would you like this spec to stay strictly negative-path coverage? If yes, we could simplify by removing expectError/else to make intent explicit. If you want mixed coverage, maybe add one valid API-surface case so the success path is also tested.

Either direction works — mostly suggesting this for clarity and future maintenance.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi @nachandr ,

One small question on test intent: in the current cases, every entry sets expectError: true, so the success branch (else) is never exercised. Would you like this spec to stay strictly negative-path coverage? If yes, we could simplify by removing expectError/else to make intent explicit. If you want mixed coverage, maybe add one valid API-surface case so the success path is also tested.

Either direction works — mostly suggesting this for clarity and future maintenance.

Hi @msajidmansoori12 ,
This test is strictly for malformed scenarios since the valid API surface scenarios are being covered by other offline tests. I have removed the success branch else block.

…rface file handling

Signed-off-by: Nandini Chandra <nachandr@redhat.com>
@nachandr nachandr changed the title crane validate offline : Automate test for malformed API surface file handling 🧪 crane validate offline : Automate test for malformed API surface file handling Jul 2, 2026
@nachandr nachandr changed the title 🧪 crane validate offline : Automate test for malformed API surface file handling 🧪 crane validate offline mode : Automate test for malformed API surface file handling Jul 2, 2026

@msajidmansoori12 msajidmansoori12 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@nachandr nachandr merged commit 12bbeea into migtools:main Jul 3, 2026
8 of 9 checks passed
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.

Test and automate: (tier1) Offline mode : Verify behavior with malformed API surface JSON file

2 participants