JosefNemec/Playnite · error · NotSupportedException

Uknown ReleaseDate string format.

Error message

Uknown ReleaseDate string format.

What it means

Thrown by ReleaseDate.Deserialize when the input string splits on '-' into more than 3 segments. Valid serialized forms are 'yyyy', 'yyyy-MM', 'yyyy-MM-dd'; anything with 4+ dash-separated parts (or an empty leading/trailing dash producing extra segments) is rejected as an unknown format.

Source

Thrown at source/PlayniteSDK/Models/ReleaseDate.cs:269

                throw new ArgumentNullException(nameof(stringDate));
            }

            var split = stringDate.Split(serSplitter);
            if (split.Length == 3)
            {
                return new ReleaseDate(int.Parse(split[0]), int.Parse(split[1]), int.Parse(split[2]));
            }
            else if (split.Length == 2)
            {
                return new ReleaseDate(int.Parse(split[0]), int.Parse(split[1]));
            }
            else if (split.Length == 1)
            {
                return new ReleaseDate(int.Parse(split[0]));
            }
            else
            {
                throw new NotSupportedException("Uknown ReleaseDate string format.");
            }
        }

        /// <inheritdoc/>
        public override string ToString()
        {
            if (Day != null)
            {
                return Date.ToString(CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern);
            }
            else if (Month != null)
            {
                return Date.ToString(CultureInfo.CurrentCulture.DateTimeFormat.YearMonthPattern);
            }
            else
            {
                return Year.ToString();
            }

View on GitHub (pinned to 5911f4e964)

Solutions

  1. Normalize the input to 'yyyy', 'yyyy-MM', or 'yyyy-MM-dd' before calling Deserialize.
  2. If a full date/time string is possible, parse it to DateTime first and construct ReleaseDate via the DateTime constructor overload.
  3. Strip leading/trailing dashes and collapse repeated separators.
  4. Wrap Deserialize in try/catch (NotSupportedException / FormatException from int.Parse) when ingesting untrusted metadata.

Example fix

// before
var d = ReleaseDate.Deserialize("2020-01-02-00-00"); // throws

// after
if (DateTime.TryParse(raw, out var dt))
    date = new ReleaseDate(dt);
else if (ReleaseDate.TryParse(raw, out date)) { /* ok */ }
else date = ReleaseDate.Empty;
Defensive patterns

Strategy: try-catch

Validate before calling

// Prefer TryParse where available; otherwise validate segment count:
var parts = stringDate.Split('-');
if (parts.Length < 1 || parts.Length > 3 || parts.Any(p => !int.TryParse(p, out _)))
    throw new FormatException($"Invalid ReleaseDate '{stringDate}'.");
return ReleaseDate.Deserialize(stringDate);

Type guard

static bool IsValidReleaseDateString(string s)
{
    if (string.IsNullOrEmpty(s)) return false;
    var p = s.Split('-');
    return p.Length >= 1 && p.Length <= 3 && p.All(x => int.TryParse(x, out _));
}

Try / catch

ReleaseDate date;
try { date = ReleaseDate.Deserialize(raw); }
catch (NotSupportedException) { date = ReleaseDate.Empty; } // or log + skip record
// or prefer: ReleaseDate.TryParse(raw, out date)

Prevention

When it happens

Trigger: ReleaseDate.Deserialize(stringDate) is called; stringDate.Split('-') yields Length > 3 (e.g. '2020-01-02-03', '-2020', '2020--01', or '2020-01-02-extra'). The else branch at line 267 throws NotSupportedException.

Common situations: Manual edit of a serialized game release date field, a metadata import produced a malformed value, a full ISO timestamp ('2020-01-02T00-00-00') landed in the field, or a leading/trailing/double dash inflated the segment count.

Related errors


AI-assisted analysis of JosefNemec/Playnite@5911f4e964 (2026-08-13). Data as JSON: /api/errors/f85c6bb5a62267ee. Report an issue: GitHub.