{"record":{"id":"dfbdb1ce080326bf","repo":"squidfunk/mkdocs-material","slug":"expected-created-date-when-using-dictionary-synt","errorCode":null,"errorMessage":"Expected 'created' date when using dictionary syntax","messagePattern":"Expected 'created' date when using dictionary syntax","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"src/plugins/blog/structure/options.py","lineNumber":99,"sourceCode":"            # only supplied a date, and convert it to datetime in UTC\n            if isinstance(value, date):\n                config[key_name][key] = datetime.combine(value, time()).replace(tzinfo=timezone.utc)\n\n        # Initialize date dictionary\n        config[key_name] = DateDict(config[key_name])\n\n    # Ensure each date value is of type datetime\n    def run_validation(self, value: DateDict):\n        for key in value:\n            if not isinstance(value[key], datetime):\n                raise ValidationError(\n                    f\"Expected type: {date} or {datetime} \"\n                    f\"but received: {type(value[key])}\"\n                )\n\n        # Ensure presence of `date.created`\n        if not value.created:\n            raise ValidationError(\n                \"Expected 'created' date when using dictionary syntax\"\n            )\n\n        # Return date dictionary\n        return value\n\n# -----------------------------------------------------------------------------\n\n# Post links option\nclass PostLinks(BaseConfigOption[Navigation]):\n\n    # Create navigation from structured items - we don't need to provide a\n    # configuration object to the function, because it will not be used\n    def run_validation(self, value: object):\n        items = _data_to_navigation(value, Files([]), None)\n        _add_parent_links(items)\n\n        # Return navigation","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/squidfunk/mkdocs-material/blob/e2136532f40aed98af1f6497c0cc6a3cff9f759b/src/plugins/blog/structure/options.py#L81-L117","documentation":"When the `date` metadata is given as a dictionary (rather than a single date), the schema requires a `created` key, which the plugin uses for sorting and display. If the DateDict has no `created` entry, `run_validation` raises this ValidationError.","triggerScenarios":"A post defines `date` as a mapping containing only keys like `updated` or `release`, without `created`, e.g. `date: {updated: 2024-02-01}`.","commonSituations":"Authors adding an `updated` date assuming it can stand alone; copying partial front-matter examples; migrating posts that previously used only an `updated` field.","solutions":["Add a `created` key to the date dictionary: `date: {created: 2024-01-15, updated: 2024-02-01}`","Or replace the dictionary with a single date value `date: 2024-01-15`, which is treated as the creation date"],"exampleFix":"# before\n---\ndate:\n  updated: 2024-02-01\n---\n\n// after\n---\ndate:\n  created: 2024-01-15\n  updated: 2024-02-01\n---","handlingStrategy":"validation","validationCode":"import yaml\nfor p in Path('docs/posts').rglob('*.md'):\n    meta = yaml.safe_load(p.read_text().split('---')[1])\n    d = meta.get('date')\n    if isinstance(d, dict):\n        assert 'created' in d, f\"{p}: dictionary date syntax requires 'created'\"\n","typeGuard":"def has_created_date(date_value):\n    return not isinstance(date_value, dict) or 'created' in date_value\n","tryCatchPattern":"try:\n    mkdocs.commands.build(config)\nexcept ValidationError as e:\n    if \"Expected 'created' date\" in str(e):\n        log.error(\"Add 'created' to the date dictionary in the post\")\n    raise\n","preventionTips":["When using dictionary date syntax, always include `created` first","Use the plain `date: YYYY-MM-DD` form when only a creation date is needed","Keep a canonical front-matter template for new posts"],"tags":["mkdocs","blog-plugin","validation","date","missing-field"],"backgroundTag":"missing-required-field","analyzedSha":"e2136532f40aed98af1f6497c0cc6a3cff9f759b","analyzedAt":"2026-08-29T11:20:04.299Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}