registerTemplate / registerIso accept a 2048-character URL, but vm_template.url holds 1024

Đang mở Phù hợp với người mới
#14,715 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
77/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java, sql
Lĩnh vực
cloud, database

Hướng nghiên cứu

Đọc RegisterTemplateCmd, RegisterIsoCmd và VMTemplateVO, sau đó so sánh độ dài URL của chúng với định nghĩa vm_template.url và các script nâng cấp hiện có. Làm theo mẫu migration trong schema-41900to41910.sql và kiểm tra cách các cột URL liên quan được mở rộng. Công việc hoàn tất khi giới hạn của cơ sở dữ liệu khớp với độ dài URL được chấp nhận và script nâng cấp được áp dụng thành công.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

problem

registerTemplate and registerIso declare their url parameter with length = 2048, and VMTemplateVO maps the column with length = 2048. The column itself is VARCHAR(1024): #8675 (the fix for #8669, released in 4.19.1) widened it from 255 to 1024 in schema-41900to41910.sql, and no later upgrade script changes it.

A URL of 1025 to 2048 characters therefore passes the API's length check and fails afterwards, when the template row is written. The caller gets a generic internal error that names neither the URL nor a limit: seen in practice with a presigned URL of about 1700 characters, which came back as HTTP 530 with cserrorcode 4250. The cause given here is from reading the source.

URLs of that length are ordinary for object storage. An S3 presigned URL signed with temporary credentials (an instance role, a task role, an assumed role) carries an X-Amz-Security-Token of about a thousand characters and usually comes to 1500–1800 characters in all. The same object signed with a long-lived access key gives a URL of 500–600 characters, which registers. #8669 was this trigger at the old 255 limit.

The sibling columns were widened to 2048 back in 4.8 (schema-471to480.sql: template_store_ref.url, volume_store_ref.url, volume_store_ref.download_url, upload.url, image_store.url). vm_template.url is the one left behind.

versions

Read in the source at tags 4.20.0.0 and 4.23.0.0 and on main (2026-11-16): RegisterTemplateCmd, RegisterIsoCmd, VMTemplateVO, schema-41900to41910.sql. By the upgrade scripts, every release from 4.19.1 on has the 1024 column.

The steps to reproduce the bug
  1. Take any reachable template URL and pad its query string until the whole URL is longer than 1024 characters and shorter than 2048 (or presign an S3 object with temporary credentials).
  2. Call registerTemplate (or registerIso) with it.
  3. The call fails with a generic internal error instead of registering the template.

A URL of 1024 characters or fewer for the same object registers.

What to do about it?

Widen vm_template.url to VARCHAR(2048) in an upgrade script, so the column matches the API parameter, the VO and the sibling tables. Failing that, lower the parameter's length to 1024 so the API refuses the URL with a message that names the limit.

Ngôn ngữ chính
Java
Star
3.1k
Fork
1.4k
Merge trung bình
7 ngày 4 giờ
Pull request đã merge (30 ngày)
13

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/cloudstack

Tất cả issue của apache/cloudstack

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.