siyuan-note/siyuan · info · ErrPluginPublishMissing

plugin publish data has not been generated

Error message

plugin publish data has not been generated

What it means

ErrPluginPublishMissing indicates the plugin publish data state exists (authorization may be fine) but its data map is nil — i.e. no publish data has been generated/saved yet for this plugin. LoadPluginPublishData raises it before reading fields. The API layer maps it to HTTP 404 Not Found.

Solutions

  1. Call the publish-data save endpoint (SavePluginPublishData / SetPluginPublishData...) once to initialize the data map before loading
  2. Treat 404 as 'initialize needed' in the client and fall back to an empty object
  3. Check that plugins/<name>/publish state file exists under the workspace and was not deleted

Example fix

// before
data, err := model.LoadPluginPublishData(name)
// after
if errors.Is(err, model.ErrPluginPublishMissing) {
    data = map[string]json.RawMessage{} // first read before any data saved
} else if err != nil {
    return err
}
Defensive patterns

Strategy: fallback

Try / catch

try {
  data = await fetchPost("/api/publish/loadPluginPublishData", {name});
} catch (e) {
  if (e.code === 404) data = {}; // not generated yet
  else throw e;
}

Prevention

When it happens

Trigger: LoadPluginPublishData(name) when the reconciled pluginPublishState has Data == nil — typically the very first read before any SetPluginPublishData/save call; TestPluginPublishDataLifecycle exercises the fresh-install case.

Common situations: Calling the publish data API for a freshly installed plugin before the plugin ever persisted its publish data; the state file was recreated after plugin reinstall; a plugin upgrade reset the data map while authorization persisted.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/8a4ad13c2b02b593. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/plugin_publish.go:22

	"bytes"
	"encoding/json"
	"errors"
	"io"
	"os"
	"path/filepath"
	"slices"
	"strings"
	"sync"

	"github.com/88250/gulu"
	"github.com/gin-gonic/gin"
	"github.com/siyuan-note/siyuan/kernel/bazaar"
	"github.com/siyuan-note/siyuan/kernel/util"
)

var (
	ErrPluginPublishDenied  = errors.New("plugin publish access denied")
	ErrPluginPublishMissing = errors.New("plugin publish data has not been generated")
	ErrPluginPublishInvalid = errors.New("invalid plugin publish declaration or data")
	pluginPublishLock       sync.Mutex
)

// PluginPublishDeclaration 的资源为精确文件名,数据为可公开的顶层标量字段,不支持目录或通配符。
type PluginPublishDeclaration struct {
	Resources []string `json:"resources"`
	Data      []string `json:"data"`
}

type PluginPublishInfo struct {
	Resources []string `json:"resources"`
	Fields    []string `json:"fields"`
	Granted   bool     `json:"granted"`
}

type pluginPublishState struct {
	Version int                        `json:"version"`

View on GitHub (pinned to 9f775e8a12)