usememos/memos · error

generalSetting.weekStartDayOffset must be between -1 and 6

Error message

generalSetting.weekStartDayOffset must be between -1 and 6

What it means

Thrown when a GENERAL instance-setting deployment file sets generalSetting.weekStartDayOffset outside the accepted range of -1 to 6 inclusive (-1 typically means browser-default; 0-6 map to Sunday-Saturday). Out-of-range values would produce undefined calendar behavior in the UI, so the deployment loader rejects the file at startup.

Source

Thrown at store/deployment_config.go:229

	for i, scope := range config.Scopes {
		if strings.TrimSpace(scope) == "" {
			return errors.Errorf("config.oauth2Config.scopes[%d] must not be empty", i)
		}
	}
	if config.FieldMapping == nil || strings.TrimSpace(config.FieldMapping.Identifier) == "" {
		return errors.New("config.oauth2Config.fieldMapping.identifier is required")
	}
	return nil
}

func validateAndNormalizeDeploymentInstanceSetting(setting *storepb.InstanceSetting) error {
	switch setting.Key {
	case storepb.InstanceSettingKey_GENERAL:
		if setting.GetGeneralSetting() == nil {
			return errors.New("generalSetting must be populated for key GENERAL")
		}
		if offset := setting.GetGeneralSetting().WeekStartDayOffset; offset < -1 || offset > 6 {
			return errors.New("generalSetting.weekStartDayOffset must be between -1 and 6")
		}
	case storepb.InstanceSettingKey_STORAGE:
		storage := setting.GetStorageSetting()
		if storage == nil {
			return errors.New("storageSetting must be populated for key STORAGE")
		}
		// Normalization would silently self-heal this misconfiguration to LOCAL;
		// a deployment file declaring S3 without a config should fail loudly.
		if storage.StorageType == storepb.InstanceStorageSetting_S3 && storage.S3Config == nil && len(storage.Storages) == 0 {
			return errors.New("storageSetting.s3Config is required for S3")
		}
		NormalizeInstanceStorageSetting(storage)
		if storage.UploadSizeLimitMb < 0 {
			return errors.New("storageSetting.uploadSizeLimitMb must not be negative")
		}
		defaultStorage := GetDefaultStorage(storage)
		if defaultStorage != nil && defaultStorage.Type == storepb.StorageType_STORAGE_TYPE_S3 {
			s3Config := defaultStorage.GetS3Config()

View on GitHub (pinned to 14d757ce1f)

Solutions

  1. Set weekStartDayOffset to -1 (browser default) or 0-6 (Sunday through Saturday).
  2. Double-check the mapping in the admin UI's Week start setting and mirror that integer.

Example fix

// before
{ "key": "GENERAL", "generalSetting": { "weekStartDayOffset": 7 } }

// after
{ "key": "GENERAL", "generalSetting": { "weekStartDayOffset": 6 } }
Defensive patterns

Strategy: validation

Validate before calling

if offset := setting.GetGeneralSetting().GetWeekStartDayOffset(); offset < -1 || offset > 6 {
    return fmt.Errorf("weekStartDayOffset %d out of range [-1,6]", offset)
}

Type guard

func isValidWeekStartDayOffset(offset int32) bool { return offset >= -1 && offset <= 6 }

Prevention

When it happens

Trigger: A memos-instance-setting-general.json with "weekStartDayOffset": 7, a negative value below -1, or a copy-paste where the offset is treated as 1-based (e.g. 7 for Saturday).

Common situations: Converting from a locale string (e.g. ISO week starting Monday = 1) and off-by-one mistakes; feeding a day name or boolean instead of the integer enum.

Related errors


AI-assisted analysis of usememos/memos@14d757ce1f (2026-08-15). Data as JSON: /api/errors/a1169b39bf374ae1. Report an issue: GitHub.