Skip to content

Conversation

@andrewstillv15
Copy link
Contributor

@andrewstillv15 andrewstillv15 commented Jan 15, 2026

Resolves #

Problem

I think this fully resolves the underlying cause of OpsLevel/terraform-provider-opslevel#617, unless I've misunderstood the issue. Manual testing I performed below.

Solution

Claude code wrote this lovely emoji filled manual test for me to validate the changes.

func ServiceSystemTest(client *opslevel.Client) {
	fmt.Println("=== Testing service.GetSystem() ===")

	// Find a service with a parent system
	services, err := client.ListServices(nil)
	if err != nil {
		fmt.Printf("❌ Failed to list services: %v\n", err)
		return
	}

	if len(services.Nodes) == 0 {
		fmt.Println("❌ No services found")
		return
	}

	var testService *opslevel.Service
	for _, svc := range services.Nodes {
		if svc.Parent != nil {
			testService = &svc
			fmt.Printf("Found service with parent system:\n")
			fmt.Printf("  Service ID: %s\n", svc.Id)
			fmt.Printf("  Service Name: %s\n", svc.Name)
			fmt.Printf("  Parent System ID (from service.Parent): %s\n\n", svc.Parent.Id)
			break
		}
	}

	if testService == nil {
		fmt.Println("❌ No services found with a parent system")
		return
	}

	// Test GetSystem() - queries the 'parent' field to get full System data
	fmt.Println("Calling service.GetSystem() to fetch full system details...")
	system, err := testService.GetSystem(client, nil)
	if err != nil {
		fmt.Printf("❌ GetSystem() FAILED: %v\n", err)
		return
	}

	if system == nil {
		fmt.Println("❌ GetSystem() returned nil (no error but no system)")
		return
	}

	// Success! Display all the system fields we retrieved
	fmt.Printf("\n✅ GetSystem() SUCCEEDED! Full system data retrieved:\n")
	fmt.Printf("  System ID: %s\n", system.Id)
	fmt.Printf("  System Name: %s\n", system.Name)
	fmt.Printf("  System Description: %s\n", system.Description)
	fmt.Printf("  System Aliases: %v\n", system.Aliases)
	if system.Owner.OnTeam.Id != "" {
		fmt.Printf("  System Owner: Team %s (ID: %s)\n", system.Owner.OnTeam.Alias, system.Owner.OnTeam.Id)
	}
	fmt.Printf("\n✅ Test passed: service.GetSystem() correctly queries 'parent' field\n")
}

Checklist

  • I have run this code, and it appears to resolve the stated issue.
  • This PR does not reduce total test coverage
  • This PR has no user interface changes or has already received approval from product management to change the interface.
  • Does this change require a Terraform schema change?
    • If so what is the ticket or PR #
  • Make a changie entry that explains the customer facing outcome of this change

… pagination variables as parent is not paginated
@andrewstillv15 andrewstillv15 merged commit 870b631 into main Jan 15, 2026
4 checks passed
@andrewstillv15 andrewstillv15 deleted the andrew/service-system-query-correctness branch January 15, 2026 18:47
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