plandex-ai/plandex · error

failed to get file map: %v

Error message

failed to get file map: %v

What it means

In the concurrent file-map worker, each batch calls api.Client.GetFileMap; on apiErr the goroutine sends this wrapped error into errCh. It means the server-side map generation for one or more batches failed, aborting the overall map operation.

Source

Thrown at app/cli/lib/context_shared.go:155

func processMapBatches(mapInputBatches []shared.FileMapInputs) (shared.FileMapBodies, error) {
	allMapBodies := shared.FileMapBodies{}

	var mapMu sync.Mutex
	errCh := make(chan error, len(mapInputBatches))

	for _, batch := range mapInputBatches {
		if len(batch) == 0 {
			errCh <- nil
			continue
		}

		go func(batch shared.FileMapInputs) {
			mapRes, apiErr := api.Client.GetFileMap(shared.GetFileMapRequest{
				MapInputs: batch,
			})
			if apiErr != nil {
				errCh <- fmt.Errorf("failed to get file map: %v", apiErr)
				return
			}
			mapMu.Lock()
			for path, bodies := range mapRes.MapBodies {
				allMapBodies[path] = bodies
			}
			mapMu.Unlock()
			errCh <- nil
		}(batch)
	}

	for i := 0; i < len(mapInputBatches); i++ {
		err := <-errCh
		if err != nil {
			return nil, err
		}
	}

View on GitHub (pinned to e2d772072e)

Solutions

  1. Retry the map operation — batch failures are often transient rate limits
  2. Reduce the number of files mapped at once to shrink batch concurrency
  3. Re-authenticate if the session expired during the run

Example fix

// before
mapRes, apiErr := api.Client.GetFileMap(shared.GetFileMapRequest{MapInputs: batch})
if apiErr != nil {
    errCh <- fmt.Errorf("failed to get file map: %v", apiErr)
    return
}
// after — bounded retry for transient failures
var mapRes *shared.GetFileMapResponse
var apiErr error
for attempt := 0; attempt < 3; attempt++ {
    mapRes, apiErr = api.Client.GetFileMap(shared.GetFileMapRequest{MapInputs: batch})
    if apiErr == nil {
        break
    }
    time.Sleep(time.Duration(1<<attempt) * time.Second)
}
if apiErr != nil {
    errCh <- fmt.Errorf("failed to get file map: %v", apiErr)
    return
}
Defensive patterns

Strategy: retry

Validate before calling

if len(batch.Paths) == 0 {
    return nil
}
if err := checkApiReachable(); err != nil {
    return fmt.Errorf("API unreachable before mapping: %w", err)
}

Try / catch

select {
case err := <-errCh:
    if isTransient(err) { // rate limit / 5xx
        time.Sleep(backoff)
        return getFileMapWithRetry(batches)
    }
    return fmt.Errorf("failed to get file map: %v", err)
case res := <-doneCh:
    return res, nil
}

Prevention

When it happens

Trigger: api.Client.GetFileMap(shared.GetFileMapRequest{MapInputs: batch}) fails for a batch — API outage, rate limiting on large batch fan-out, auth expiry, or server 5xx while mapping many files.

Common situations: Mapping very large repos producing many concurrent batches (rate limits); VPN/proxy interruptions; expired session mid-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 plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/adb87210ad7727dd. Report an issue: GitHub.