From bea8aad6b82c66d58525b67bc04340fd5adae54b Mon Sep 17 00:00:00 2001 From: Seongmin Lee Date: Thu, 27 Aug 2026 18:42:31 +0900 Subject: [PATCH] lexicons,api,appview,web: require `repo` field in `ci.pipeline` Signed-off-by: Seongmin Lee --- api/tangled/cbor_gen.go | 61 ++++++------------- api/tangled/cipipeline.go | 2 +- appview/pipelines/pipelines.go | 4 +- lexicons/ci/pipeline.json | 2 +- spindle/db/pipelines.go | 2 +- spindle/db/pipelines_test.go | 2 +- spindle/xrpc/pipeline_cancel_pipeline.go | 2 +- .../lexicons/types/sh/tangled/ci/pipeline.ts | 2 +- 8 files changed, 27 insertions(+), 50 deletions(-) diff --git a/api/tangled/cbor_gen.go b/api/tangled/cbor_gen.go index 27dd6f204..8930209f4 100644 --- a/api/tangled/cbor_gen.go +++ b/api/tangled/cbor_gen.go @@ -675,10 +675,6 @@ func (t *CiPipeline) MarshalCBOR(w io.Writer) error { fieldCount-- } - if t.Repo == nil { - fieldCount-- - } - if t.SourceRepo == nil { fieldCount-- } @@ -711,35 +707,26 @@ func (t *CiPipeline) MarshalCBOR(w io.Writer) error { } // t.Repo (string) (string) - if t.Repo != nil { - - if len("repo") > 1000000 { - return xerrors.Errorf("Value in field \"repo\" was too long") - } + if len("repo") > 1000000 { + return xerrors.Errorf("Value in field \"repo\" was too long") + } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repo"))); err != nil { - return err - } - if _, err := cw.WriteString(string("repo")); err != nil { - return err - } + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repo"))); err != nil { + return err + } + if _, err := cw.WriteString(string("repo")); err != nil { + return err + } - if t.Repo == nil { - if _, err := cw.Write(cbg.CborNull); err != nil { - return err - } - } else { - if len(*t.Repo) > 1000000 { - return xerrors.Errorf("Value in field t.Repo was too long") - } + if len(t.Repo) > 1000000 { + return xerrors.Errorf("Value in field t.Repo was too long") + } - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Repo))); err != nil { - return err - } - if _, err := cw.WriteString(string(*t.Repo)); err != nil { - return err - } - } + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Repo))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Repo)); err != nil { + return err } // t.Commit (string) (string) @@ -929,22 +916,12 @@ func (t *CiPipeline) UnmarshalCBOR(r io.Reader) (err error) { case "repo": { - b, err := cr.ReadByte() + sval, err := cbg.ReadStringWithMax(cr, 1000000) if err != nil { return err } - if b != cbg.CborNull[0] { - if err := cr.UnreadByte(); err != nil { - return err - } - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.Repo = (*string)(&sval) - } + t.Repo = string(sval) } // t.Commit (string) (string) case "commit": diff --git a/api/tangled/cipipeline.go b/api/tangled/cipipeline.go index 290917ad9..c12d818b8 100644 --- a/api/tangled/cipipeline.go +++ b/api/tangled/cipipeline.go @@ -25,7 +25,7 @@ type CiPipeline struct { // id: Spindle-local pipeline id Id string `json:"id" cborgen:"id"` // repo: Repository DID - Repo *string `json:"repo,omitempty" cborgen:"repo,omitempty"` + Repo string `json:"repo" cborgen:"repo"` // sourceRepo: Repository DID that the commit was checked out from, if different from repo (e.g. a fork for a fork-based pull request) SourceRepo *string `json:"sourceRepo,omitempty" cborgen:"sourceRepo,omitempty"` // trigger: Trigger event metadata diff --git a/appview/pipelines/pipelines.go b/appview/pipelines/pipelines.go index 38361eae1..bd2768e78 100644 --- a/appview/pipelines/pipelines.go +++ b/appview/pipelines/pipelines.go @@ -201,7 +201,7 @@ func (p *Pipelines) Index(w http.ResponseWriter, r *http.Request) { var pipelines []types.Pipeline for _, pipeline := range out.Pipelines { - if pipeline.Repo == nil || *pipeline.Repo != f.RepoDid { + if pipeline.Repo != f.RepoDid { l.Warn("spindle returned pipeline for unexpected repo", "want", f.RepoDid, "got", pipeline.Repo, "spindle", f.Spindle) continue @@ -269,7 +269,7 @@ func (p *Pipelines) Workflow(w http.ResponseWriter, r *http.Request) { return } - if out.Repo == nil || *out.Repo != f.RepoDid { + if out.Repo != f.RepoDid { l.Debug("spindle returned pipeline for unexpected repo", "want", f.RepoDid, "got", out.Repo) p.pages.Error404(w) return diff --git a/lexicons/ci/pipeline.json b/lexicons/ci/pipeline.json index 33e81cc4f..249609449 100644 --- a/lexicons/ci/pipeline.json +++ b/lexicons/ci/pipeline.json @@ -5,7 +5,7 @@ "main": { "type": "object", "description": "A CI pipeline. Record-like, but owned by the spindle rather than a PDS.", - "required": ["id", "trigger", "commit", "workflows"], + "required": ["id", "repo", "trigger", "commit", "workflows"], "properties": { "id": { "type": "string", diff --git a/spindle/db/pipelines.go b/spindle/db/pipelines.go index 028f13f8c..d93208fd9 100644 --- a/spindle/db/pipelines.go +++ b/spindle/db/pipelines.go @@ -221,7 +221,7 @@ func (d *DB) mapToCiPipeline(rkey string, created int64, raw tangled.Pipeline) ( return &tangled.CiPipeline{ Id: rkey, Commit: commitSha, - Repo: &repoDidStr, + Repo: repoDidStr, CreatedAt: &createdAtStr, Trigger: &trigger, Workflows: workflows, diff --git a/spindle/db/pipelines_test.go b/spindle/db/pipelines_test.go index 71e9bddcb..640ecf382 100644 --- a/spindle/db/pipelines_test.go +++ b/spindle/db/pipelines_test.go @@ -97,7 +97,7 @@ func TestQueryPipelines_KindScopedToRepo(t *testing.T) { if total != 1 || len(pipelines) != 1 { t.Fatalf("total=%d len=%d, want exactly alice's single push pipeline", total, len(pipelines)) } - if pipelines[0].Repo == nil || *pipelines[0].Repo != "did:plc:alice" { + if pipelines[0].Repo != "did:plc:alice" { t.Errorf("returned pipeline repo = %v, want did:plc:alice", pipelines[0].Repo) } } diff --git a/spindle/xrpc/pipeline_cancel_pipeline.go b/spindle/xrpc/pipeline_cancel_pipeline.go index fc883157f..71dce36e6 100644 --- a/spindle/xrpc/pipeline_cancel_pipeline.go +++ b/spindle/xrpc/pipeline_cancel_pipeline.go @@ -56,7 +56,7 @@ func (x *Xrpc) CancelPipeline(w http.ResponseWriter, r *http.Request) { fail(xrpcerr.GenericError(fmt.Errorf("failed to get pipeline: %w", err))) return } - if p.Repo == nil || *p.Repo != repoDid.String() { + if p.Repo != repoDid.String() { fail(xrpcerr.AccessControlError(actorDid.String())) return } diff --git a/web/src/lib/api/lexicons/types/sh/tangled/ci/pipeline.ts b/web/src/lib/api/lexicons/types/sh/tangled/ci/pipeline.ts index 1a5c6db93..cbe5ebb83 100644 --- a/web/src/lib/api/lexicons/types/sh/tangled/ci/pipeline.ts +++ b/web/src/lib/api/lexicons/types/sh/tangled/ci/pipeline.ts @@ -18,7 +18,7 @@ const _mainSchema = /*#__PURE__*/ v.object({ /** * Repository DID */ - repo: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.didString()), + repo: /*#__PURE__*/ v.didString(), /** * Repository DID that the commit was checked out from, if different from repo (e.g. a fork for a fork-based pull request) */ -- 2.51.2