goharbor/harbor · error

missing cron spec for periodic job

Error message

missing cron spec for periodic job

What it means

Validate on job Stats rejects the record because JobKind is KindPeriodic while Info.CronSpec is empty: a periodic job cannot be scheduled without a cron expression. Validate is invoked via New when a job stats model is constructed.

Solutions

  1. Set a valid cron expression (e.g. '*/5 * * * *') in Info.CronSpec before calling New/Validate for periodic jobs
  2. If the job is meant to run once, use KindGeneric; for a one-shot future run use KindScheduled with RunAt set
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/jobservice/job/models.go:146 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of goharbor/harbor@7b2fd08cc5 (2026-08-16). Data as JSON: /api/errors/8e84c7010a09c508. Report an issue: GitHub.

Appendix: source

Thrown at src/jobservice/job/models.go:146

	if utils.IsEmptyStr(st.Info.JobKind) {
		return errors.New("missing job name in job stats")
	}

	if st.Info.JobKind != KindGeneric &&
		st.Info.JobKind != KindPeriodic &&
		st.Info.JobKind != KindScheduled {
		return errors.Errorf("job kind is not supported: %s", st.Info.JobKind)
	}

	status := Status(st.Info.Status)
	if err := status.Validate(); err != nil {
		return err
	}

	if st.Info.JobKind == KindPeriodic {
		if utils.IsEmptyStr(st.Info.CronSpec) {
			return errors.New("missing cron spec for periodic job")
		}
	}

	if st.Info.JobKind == KindScheduled {
		if st.Info.RunAt == 0 {
			return errors.New("enqueue timestamp missing for scheduled job")
		}
	}

	return nil
}

// Config job service config
type Config struct {
	RedisPoolConfig *config.RedisPoolConfig `json:"redis_pool_config"`
}

View on GitHub (pinned to 7b2fd08cc5)