Skip to content

Support tag_ids on JSON card create/update#2830

Draft
robzolkos wants to merge 11 commits intobasecamp:mainfrom
robzolkos:bugfix/card-create-tag-ids-api
Draft

Support tag_ids on JSON card create/update#2830
robzolkos wants to merge 11 commits intobasecamp:mainfrom
robzolkos:bugfix/card-create-tag-ids-api

Conversation

@robzolkos
Copy link
Copy Markdown
Collaborator

@robzolkos robzolkos commented Apr 9, 2026

Summary

The cards JSON API already documents support for tag_ids, but CardsController was not wrapping or permitting that parameter. As a result, API clients could create or update cards successfully while tags were silently dropped from the request and the response came back with an empty tags array.

This change makes tag_ids work for JSON card create/update requests so the API behavior matches the docs and client expectations. It also validates that assigned tags belong to the card's account and returns standard unprocessable-entity responses for invalid tag assignments.

Ref: #2819

Changes

  • permit tag_ids: [] in CardsController#card_params
  • include tag_ids in wrap_parameters :card so flat JSON payloads work too
  • validate that assigned tags belong to the card account
  • return validation errors with 422 Unprocessable Entity for invalid JSON card create/update requests
  • re-render the edit template with 422 Unprocessable Entity for invalid HTML card updates
  • add regression coverage for:
    • nested JSON create with card: { tag_ids: [...] }
    • flat JSON create with tag_ids: [...]
    • nested JSON update with card: { tag_ids: [...] }
    • flat JSON update with tag_ids: [...]
    • clearing tags with tag_ids: []
    • preserving existing tags when tag_ids is omitted from an update
    • invalid HTML updates rendering the edit form again

Notes

  • no docs update was needed because the API docs already list tag_ids for card create/update
  • nonexistent tag IDs still return 404 Not Found
  • foreign-account tag IDs are treated as invalid and return 422 Unprocessable Entity

Copilot AI review requested due to automatic review settings April 9, 2026 21:45
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@rbarbosa
Copy link
Copy Markdown

Glad to see this coming to light! #2340

@robzolkos robzolkos marked this pull request as draft April 11, 2026 17:59
@robzolkos robzolkos removed the request for review from flavorjones April 11, 2026 17:59
@robzolkos robzolkos force-pushed the bugfix/card-create-tag-ids-api branch from e33603a to 7a1bedf Compare April 13, 2026 13:53
@robzolkos robzolkos marked this pull request as ready for review April 13, 2026 14:46
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@robzolkos robzolkos requested a review from flavorjones April 13, 2026 14:46
Copy link
Copy Markdown
Member

@flavorjones flavorjones left a comment

Choose a reason for hiding this comment

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

This looks great, nice simplification from the earlier version. Two edge cases I'd like to see tests for — not because I think they're necessarily broken, but because the behavior should be fully specified:

  1. Clearing tags with tag_ids: [] — the setter handles this path explicitly, so let's cover it.
  2. Update without tag_ids preserves existing tags — confirms that omitting tag_ids from an update doesn't accidentally clear tags.

Comment thread app/models/card/taggable.rb Outdated
@robzolkos robzolkos requested a review from flavorjones April 14, 2026 18:01
Comment thread test/controllers/cards_controller_test.rb
@robzolkos robzolkos requested review from flavorjones and removed request for flavorjones April 14, 2026 22:10
@robzolkos robzolkos marked this pull request as draft April 14, 2026 22:11
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.

3 participants