Skip to content

bug(api): menu item custom_url not persisted via REST API POST #932

@Vallhalen

Description

@Vallhalen

Bug

POST /_emdash/api/menus/:name/items with type: "link" accepts the request (201) but does not persist custom_url or url. The created item always has custom_url: null.

Reproduction

curl -X POST "https://example.com/_emdash/api/menus/primary/items" \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"type":"link","label":"Blog","custom_url":"/blog","sort_order":3}'

Response: 201 Created with "custom_url": null

Also tried "url": "/blog" — same result.

Impact

After upgrading to 0.10.0, our primary and footer menus lost all items (likely due to migration 036_i18n_menus_and_taxonomies). When trying to recreate items via REST API, the URL field is never saved, resulting in all menu links pointing to #.

Workaround

We patched getMenu() output in our layout with a label→URL fallback map:

const menuUrlMap = { 'Blog': '/blog', 'Portfolio': '/portfolio', ... };
function patchMenuUrls(m) {
  return { ...m, items: m.items.map(item => ({
    ...item,
    url: (item.url && item.url !== '#') ? item.url : menuUrlMap[item.label] || '#',
  })) };
}

Environment

  • EmDash 0.10.0
  • Cloudflare Workers + D1
  • Menu items created via REST API (not admin UI)

Additional note

DELETE /_emdash/api/menus/:name/items/:id also doesn't seem to work — returns the 404 page HTML instead of a JSON response.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions