Skip to content

(Type safety) Project.defaultIssueStatus typed as required but undefined at runtime #10597

@dearlordylord

Description

@dearlordylord

Project.defaultIssueStatus is declared as Ref<IssueStatus> (required) in plugins/tracker/src/index.ts#L64, but is undefined at runtime on Huly >=0.7.x for projects created without an explicit default status selection (workspace templates, CreateProject UI with no selection stores "").

Evidence

  • UI already handles this: StatusEditor.svelte#L107-L117 checks if (defaultIssueStatus !== undefined) and falls back to statuses?.[0].
  • CreateProject.svelte#L114 sets defaultIssueStatus: defaultStatus ?? ('' as Ref<IssueStatus>) — empty string when user doesn't pick one.
  • REST API consumers (e.g. MCP servers using @hcengineering/api-client) receive undefined for this field, causing silent failures when creating issues with the "project default" status.
  • Example of API consumers having to fix this on their side: dearlordylord/huly-mcp@f52cd84

Affected call sites

These access .defaultIssueStatus without guarding for undefined:

Proposed fix

Make the field optional in the interface and model class:

// plugins/tracker/src/index.ts
-  defaultIssueStatus: Ref<IssueStatus>
+  defaultIssueStatus?: Ref<IssueStatus>

// models/tracker/src/types.ts
-    defaultIssueStatus!: Ref<IssueStatus>
+    defaultIssueStatus?: Ref<IssueStatus>

fixed by #10598

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