Skip to content

docs(artists): POST /api/artists resolve-or-create by spotify_artist_id (chat#1889 row 8) - #278

Merged
sweetmantech merged 2 commits into
mainfrom
docs/artists-spotify-id-resolve-or-create
Jul 29, 2026
Merged

docs(artists): POST /api/artists resolve-or-create by spotify_artist_id (chat#1889 row 8)#278
sweetmantech merged 2 commits into
mainfrom
docs/artists-spotify-id-resolve-or-create

Conversation

@sweetmantech

@sweetmantech sweetmantech commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Contract-first PR for chat#1889 row 8 (dedup at creation).

POST /api/artists gains optional spotify_artist_id:

  • canonical exists → link to account, return { artist } 200
  • none → create + attach the SPOTIFY social server-side, return 201
  • omitted → unchanged (201)

Merge order: this PR → api#TBD → chat#TBD. The 2026-07-29 decision on the issue: one canonical artist per Spotify id, enforced at creation; no account-scoped canonical lookups (api#792 closed unmerged).

Edited via anchored text edits (releases.json doesn't round-trip byte-identical); re-validated the JSON parses and both the property and the 200 response resolve.

🤖 Generated with Claude Code


Summary by cubic

Adds resolve-or-create behavior to POST /api/artists using an optional spotify_artist_id to prevent duplicate artists and link accounts to the canonical record. OpenAPI now documents 200 on linking existing and 201 on creating a new artist, with copy updated to follow customer-facing style.

  • New Features
    • Optional spotify_artist_id on create.
    • If a canonical exists for that id, link it to the account and return 200 with { artist }.
    • If none exists, create the artist and attach the Spotify profile, return 201.
    • Omitting spotify_artist_id keeps existing create behavior (201).
    • OpenAPI: added 200 response and field docs; clarified “one canonical artist per Spotify id” at creation; removed em dashes in the endpoint description.

Written for commit 135ee36. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Documentation
    • Updated artist creation API documentation to support an optional Spotify artist ID.
    • Clarified that requests may link an existing artist instead of creating a duplicate.
    • Documented successful responses for both newly created and linked artists.

…r a spotify_artist_id

Optional spotify_artist_id on CreateArtistRequest: when a canonical
artist already carries the id the endpoint links it to the account and
returns 200; otherwise it creates with the Spotify profile attached
(201). Contract for the dedup-at-creation slice on chat#1889 rows 8-10:
one canonical artist per Spotify id, enforced where rows are born.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@cursor

cursor Bot commented Jul 29, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The OpenAPI specification documents optional spotify_artist_id handling for POST /api/artists, including linking an existing canonical artist with a 200 response or creating a new artist with a 201 response.

Changes

Artist API contract

Layer / File(s) Summary
Resolve-or-create request and responses
api-reference/openapi/releases.json
The CreateArtistRequest schema and POST /api/artists documentation now describe Spotify artist resolution, account linking, optional organization linkage, and 200/201 response behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: arpitgupta1214

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: POST /api/artists now resolves or creates by spotify_artist_id.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/artists-spotify-id-resolve-or-create

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@api-reference/openapi/releases.json`:
- Around line 570-579: Update the 200 response schema in the release OpenAPI
definition to use the neutral artist response schema covering both existing and
newly created artists, rather than CreateArtistResponse. Ensure the referenced
artist schema defines account_socials with a typed items schema that represents
the attached Spotify profile.
- Line 557: Clarify the endpoint description for the existing-artist resolution
path: explicitly state whether CreateArtistRequest.organization_id is applied
to, ignored for, or rejected when a canonical artist is returned, while
preserving the documented behavior for newly created artists.
- Around line 2835-2838: Constrain the optional spotify_artist_id property to
reject explicitly provided empty strings by adding a minimum length of 1 while
keeping the field optional. Preserve the existing description and endpoint
behavior for valid Spotify identifiers and omitted values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7620f8f4-e814-43a7-8881-8441f89e2be0

📥 Commits

Reviewing files that changed from the base of the PR and between ed3a821 and 4d097cb.

📒 Files selected for processing (1)
  • api-reference/openapi/releases.json

Comment thread api-reference/openapi/releases.json Outdated
},
"post": {
"description": "Create a new artist account. The artist can optionally be linked to an organization.",
"description": "Create a new artist account, or — when spotify_artist_id is provided and a canonical artist already exists for it — link that existing artist to the account instead of creating a duplicate. The artist can optionally be linked to an organization.",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Clarify organization_id for the resolve path.

This description implies organization linkage applies to any returned artist, while CreateArtistRequest.organization_id says it links the new artist. Document whether organization linkage is applied, ignored, or rejected when an existing canonical artist is resolved.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@api-reference/openapi/releases.json` at line 557, Clarify the endpoint
description for the existing-artist resolution path: explicitly state whether
CreateArtistRequest.organization_id is applied to, ignored for, or rejected when
a canonical artist is returned, while preserving the documented behavior for
newly created artists.

Comment on lines +570 to +579
"200": {
"description": "Existing canonical artist for the given spotify_artist_id linked to the account (no new artist created)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateArtistResponse"
}
}
}
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Use a typed, neutral artist response schema.

CreateArtistResponse resolves to CreatedArtist, whose account_socials array has no items schema. The new 200/201 contract therefore does not expose the shape of the server-attached Spotify profile to generated clients. Type the social entries and use a schema that accurately covers both existing and newly created artists.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@api-reference/openapi/releases.json` around lines 570 - 579, Update the 200
response schema in the release OpenAPI definition to use the neutral artist
response schema covering both existing and newly created artists, rather than
CreateArtistResponse. Ensure the referenced artist schema defines
account_socials with a typed items schema that represents the attached Spotify
profile.

Comment on lines +2835 to +2838
"spotify_artist_id": {
"type": "string",
"description": "Optional Spotify artist id. When provided, the endpoint resolves-or-creates the canonical artist for that id: if an artist already carries it, that artist is linked to the account and returned (200) instead of creating a duplicate; otherwise the artist is created with its Spotify profile attached (201)."
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n -C5 '\bspotify_artist_id\b' . \
  -g '!api-reference/openapi/releases.json'

Repository: recoupable/docs

Length of output: 153


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Files with spotify_artist_id:\n'
rg -n -C3 '\bspotify_artist_id\b' . || true

printf '\nRelevant OpenAPI section:\n'
sed -n '2828,2842p' api-reference/openapi/releases.json

printf '\nRepo file count and type evidence:\n'
git ls-files | wc -l
git ls-files | sed -n '1,120p'

Repository: recoupable/docs

Length of output: 8846


Clarify and constrain the optional Spotify artist ID.

spotify_artist_id is optional but unminlengthed, so "spotify_artist_id": "" still matches the schema even though any provided value is described as a Spotify identifier and "invalid" IDs return 400 in nearby response docs. Add minLength: 1 if empty IDs are rejected, or update the description/validation wording if empty IDs are accepted.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@api-reference/openapi/releases.json` around lines 2835 - 2838, Constrain the
optional spotify_artist_id property to reject explicitly provided empty strings
by adding a minimum length of 1 while keeping the field optional. Preserve the
existing description and endpoint behavior for valid Spotify identifiers and
omitted values.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="api-reference/openapi/releases.json">

<violation number="1" location="api-reference/openapi/releases.json:570">
P3: The new 200 response for the resolve-or-create flow reuses CreateArtistResponse, but the underlying account_socials array lacks an items schema, so generated clients won't get a typed shape for the server-attached Spotify profile. Consider typing the social entries so both the resolve and create paths accurately expose the response shape.</violation>

<violation number="2" location="api-reference/openapi/releases.json:2835">
P3: spotify_artist_id has no minLength constraint, so "spotify_artist_id": "" would still validate against the schema even though invalid IDs are documented to return 400 elsewhere. Add minLength: 1 if empty strings should be rejected, or update the description to clarify that empty values are accepted.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

"minLength": 1,
"description": "The name of the artist to create"
},
"spotify_artist_id": {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: spotify_artist_id has no minLength constraint, so "spotify_artist_id": "" would still validate against the schema even though invalid IDs are documented to return 400 elsewhere. Add minLength: 1 if empty strings should be rejected, or update the description to clarify that empty values are accepted.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At api-reference/openapi/releases.json, line 2835:

<comment>spotify_artist_id has no minLength constraint, so "spotify_artist_id": "" would still validate against the schema even though invalid IDs are documented to return 400 elsewhere. Add minLength: 1 if empty strings should be rejected, or update the description to clarify that empty values are accepted.</comment>

<file context>
@@ -2822,6 +2832,10 @@
             "minLength": 1,
             "description": "The name of the artist to create"
           },
+          "spotify_artist_id": {
+            "type": "string",
+            "description": "Optional Spotify artist id. When provided, the endpoint resolves-or-creates the canonical artist for that id: if an artist already carries it, that artist is linked to the account and returned (200) instead of creating a duplicate; otherwise the artist is created with its Spotify profile attached (201)."
</file context>

}
},
"responses": {
"200": {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: The new 200 response for the resolve-or-create flow reuses CreateArtistResponse, but the underlying account_socials array lacks an items schema, so generated clients won't get a typed shape for the server-attached Spotify profile. Consider typing the social entries so both the resolve and create paths accurately expose the response shape.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At api-reference/openapi/releases.json, line 570:

<comment>The new 200 response for the resolve-or-create flow reuses CreateArtistResponse, but the underlying account_socials array lacks an items schema, so generated clients won't get a typed shape for the server-attached Spotify profile. Consider typing the social entries so both the resolve and create paths accurately expose the response shape.</comment>

<file context>
@@ -567,6 +567,16 @@
           }
         },
         "responses": {
+          "200": {
+            "description": "Existing canonical artist for the given spotify_artist_id linked to the account (no new artist created)",
+            "content": {
</file context>

@sweetmantech

Copy link
Copy Markdown
Collaborator Author

Local render verification — Mintlify dev, all three changes confirmed

Checked out this branch locally and rendered it with npx mintlify@latest dev (v4.2.754), then drove the page with Chrome DevTools. Assertions were made against the rendered DOM text, not just eyeballed.

# Change Rendered result
1 Endpoint description "Create a new artist account. When spotify_artist_id is provided and a canonical artist already exists for it, the existing artist is linked to the account instead of creating a duplicate."
2 spotify_artist_id body param Renders as string, correctly not marked required, positioned between name and account_id, full resolve-or-create description
3 200 response Appears in the response picker alongside 201/400/500; selecting it shows "Existing canonical artist for the given spotify_artist_id linked to the account (no new artist created)" with the reused CreateArtistResponse schema (artist object)

Endpoint description (top of page):

description

The new param, in place in the body schema:

param

The 200 response, selected in the Response section:

200

Fixed during verification

135ee36 — the original endpoint description contained two em dashes. Docs are customer-facing product copy, so the no-em-dash rule applies; rewritten with plain sentences. (Caught by asserting /[—–]/ against the rendered description, which came back true on the first pass.)

Contract ↔ implementation check

The rendered contract matches api#793 exactly: same { artist } envelope on both codes, 200 only ever returned when spotify_artist_id was provided and resolved, 201 and error codes unchanged. Live reconciliation (step 6 of the loop) happens on api#793's preview after this merges.

JSON re-validated (json.load clean) after the em-dash edit. Merge order: this → api#793 → chat#1901.

@sweetmantech
sweetmantech merged commit 96169e6 into main Jul 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant