wtfutil/wtf · error

error getting sections: %s

Error message

error getting sections: %s

What it means

Returned by findSection when project.Sections fails to list the sections of the target project. The helper needs the full section list to match a section by name; an API error here (bad project GID, permissions, rate limit, network) aborts the section resolution and propagates up to fetchTasksFromProjectSections.

Source

Thrown at modules/asana/client.go:240

	if strings.HasSuffix(mode, "_all") {
		return "", nil
	}
	u, err := client.CurrentUser()
	if err != nil {
		return "", fmt.Errorf("error getting current user: %s", err)
	}

	return u.ID, nil
}

func findSection(client *asana.Client, project *asana.Project, sectionName string) (string, error) {
	sectionId := ""

	sections, _, err := project.Sections(client, &asana.Options{
		Limit: 100,
	})
	if err != nil {
		return "", fmt.Errorf("error getting sections: %s", err)
	}

	for _, section := range sections {
		if section.Name == sectionName {
			sectionId = section.ID
			break
		}
	}

	if sectionId == "" {
		return "", fmt.Errorf("we didn't find the section %s", sectionName)
	}

	return sectionId, nil
}

func getTasksFromAsana(client *asana.Client, q *asana.TaskQuery) ([]*asana.Task, bool, error) {
	moreTasks := false

View on GitHub (pinned to bb838c1ccb)

Solutions

  1. Verify the project GID: GET /projects/<gid> with the token; expect 200 and the right project name.
  2. Confirm the token can list the project's sections: GET /projects/<gid>/sections.
  3. Check for 429 in the wrapped error and add backoff/retry; the Limit:100 request is repeated per section, amplifying rate usage.
  4. If the project is archived/deleted, update the config with the current project GID.

Example fix

// before
sections, _, err := project.Sections(client, &asana.Options{Limit: 100})
if err != nil {
    return "", fmt.Errorf("error getting sections: %s", err)
}
// after
sections, _, err := project.Sections(client, &asana.Options{Limit: 100})
if err != nil {
    return "", fmt.Errorf("error getting sections for project %s: %w", project.ID, err)
}
Defensive patterns

Strategy: validation

Validate before calling

p, _, err := client.GetProjectByID(projectGID)
if err != nil {
    return fmt.Errorf("project %s not accessible: %w", projectGID, err)
}
if _, _, err := p.Sections(client, &asana.Options{Limit: 1}); err != nil {
    return fmt.Errorf("cannot list sections of %s: %w", projectGID, err)
}

Try / catch

tasks, err := mod.Fetch(ctx)
if err != nil {
    if strings.Contains(err.Error(), "error getting sections") {
        log.Printf("project %s unreachable (check GID, archive status, token): %v", projectGID, err)
        return nil
    }
    return err
}

Prevention

When it happens

Trigger: Calling fetchTasksFromProjectSections where project.Sections(client, &asana.Options{Limit:100}) errors: project GID nonexistent/archived/deleted, token lacks access to the project, Asana 429 rate limiting, or network failure.

Common situations: Project GID copied from a URL of a different workspace; project archived after config was written; token is a guest with no project access; hitting rate limits when many projects' sections are enumerated in one run.

Understand the failure class

Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.

Related errors


AI-assisted analysis of wtfutil/wtf@bb838c1ccb (2026-09-03). Data as JSON: /api/errors/31c1fe85780c7c1f. Report an issue: GitHub.