Skip to content

Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.

Say what the attachment order and the recorded URL do not promise

Guido Boyke1e22f2b919d7
diff --git a/app/controllers/api/v1/tickets_controller.rb b/app/controllers/api/v1/tickets_controller.rb
index e204514..1075668 100644
--- a/app/controllers/api/v1/tickets_controller.rb
+++ b/app/controllers/api/v1/tickets_controller.rb
@@ -273,7 +273,8 @@ module Api
# has_many_attached NOTHING in the app writes, so the list answered "none" for
# every comment that had a file while #show reported a real count — one API,
# two answers to the same question. Preloaded, because one read per
- # readable comment was an N+1; sorted by id as find_each used to order them.
+ # readable comment was an N+1. Comments come in id order (find_each), the
+ # files of one comment in id order as before; neither is creation order.
ticket.posts.readable_by(current_user, ticket.organisation)
.includes(post_documents: { post_document_file_attachment: :blob }).find_each do |post|
post.post_documents.sort_by(&:id).each do |pd|
diff --git a/spec/contracts/mcp_contract_recorder.rb b/spec/contracts/mcp_contract_recorder.rb
index c2a6408..bfc0482 100644
--- a/spec/contracts/mcp_contract_recorder.rb
+++ b/spec/contracts/mcp_contract_recorder.rb
@@ -468,6 +468,9 @@ module McpContract
# signed segment becomes a placeholder; a URL of any other form stops the
# recording instead of being written down in a form the server does not send.
# The real URL's form is pinned in spec/requests/api/v1/read_endpoints_spec.rb.
+ # Scheme and host follow the request (ActiveStorage::SetCurrent): `http` and
+ # www.example.com here, https and the instance's host behind an SSL proxy.
+ # The last segment is the file name escaped for a path; `filename` holds it.
def signed_urls_replaced(answer)
form = %r{\A(?<before>http://#{Regexp.escape(session.host)}/rails/active_storage/disk/)[^/?#]+(?<after>/[^/?#]+)\z}
answer.dig('response', 'body', 'data').each do |file|
diff --git a/spec/fixtures/mcp_contract.json b/spec/fixtures/mcp_contract.json
index 1aee2d8..5d438ce 100644
--- a/spec/fixtures/mcp_contract.json
+++ b/spec/fixtures/mcp_contract.json
@@ -1,7 +1,7 @@
{
"header": {
"regenerate": "RAILS_ENV=test bin/rails mcp:contract",
- "core_commit": "c8f6e4acf5deca9444ea3b87c75251c9246e8ec4",
+ "core_commit": "38c4d2ad6e9f191073d532fda754d5be3ddbec01",
"core_dirty": true,
"contract_sha256": "0d74f7549e9cf134b87e79ee66e48495a1698088d5828795030b98255036fd79"
},