semaphoreui/semaphore · error

error at repositories

Error message

error at repositories[%d]: %s

What it means

This error wraps a per-item failure from BackupFormat.Verify() while validating backup.Repositories: the repository object at index i failed o.Verify(backup). The backup's repositories section is inconsistent (bad fields or cross-references) and restore is refused before any DB writes happen.

Solutions

  1. Inspect the inner error after 'repositories[i]:' for the exact field problem
  2. Fix the repository entry at that index in the backup file (name, url, ssh key reference)
  3. Verify referenced keys exist earlier in the same backup (repositories are verified after keys)
  4. Re-export the backup from the source instance rather than editing it by hand

Example fix

// before
"repositories": [{"name": "repo", "ssh_key_id": 42}]
// after
"repositories": [{"name": "repo", "url": "git@github.com:org/repo.git", "ssh_key_name": "deploy-key"}]
Defensive patterns

Strategy: validation

Validate before calling

for i, r := range backup.Repositories {
    if r == nil || r.Name == "" || r.URL == "" {
        return fmt.Errorf("repositories[%d]: missing name/url before restore", i)
    }
}
if err := backup.Verify(); err != nil {
    return err
}

Type guard

func validRepository(r *RepositoryBackup) bool { return r != nil && r.Name != "" }

Try / catch

if err := backup.Verify(); err != nil {
    if strings.Contains(err.Error(), "repositories[") {
        // parse index and fix that repository entry
    }
    return err
}

Prevention

When it happens

Trigger: Calling BackupFormat.Verify() where the repository at backup.Repositories[i] fails Verify — e.g. empty repository name, missing/unknown SSH key reference, or invalid URL for the repository.

Common situations: Backups exported from another Semaphore instance with repository settings not representable in the target version; manually merged backups where a repo references a key that was dropped; corrupted YAML/JSON in the repository section.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of semaphoreui/semaphore@1774ccb71a (2026-09-07). Data as JSON: /api/errors/cd2ad1c1341441a5. Report an issue: GitHub.

Appendix: source

Thrown at services/project/restore.go:558

	}
	for i, o := range backup.Views {
		if err := o.Verify(backup); err != nil {
			return fmt.Errorf("error at views[%d]: %s", i, err.Error())
		}
	}
	for i, o := range backup.Schedules {
		if err := o.Verify(backup); err != nil {
			return fmt.Errorf("error at templates[%d]: %s", i, err.Error())
		}
	}
	for i, o := range backup.Keys {
		if err := o.Verify(backup); err != nil {
			return fmt.Errorf("error at keys[%d]: %s", i, err.Error())
		}
	}
	for i, o := range backup.Repositories {
		if err := o.Verify(backup); err != nil {
			return fmt.Errorf("error at repositories[%d]: %s", i, err.Error())
		}
	}
	for i, o := range backup.Inventories {
		if err := o.Verify(backup); err != nil {
			return fmt.Errorf("error at inventories[%d]: %s", i, err.Error())
		}
	}
	for i, o := range backup.SecretStorages {
		if err := o.Verify(backup); err != nil {
			return fmt.Errorf("error at secret storage[%d]: %s", i, err.Error())
		}
	}
	for i, o := range backup.Templates {
		if err := o.Verify(backup); err != nil {
			return fmt.Errorf("error at templates[%d]: %s", i, err.Error())
		}
	}
	for i, o := range backup.Roles {

View on GitHub (pinned to 1774ccb71a)