Skip to content

feat: implement base64-aware size validation for building_block_definition symbol#136

Merged
sttomm merged 1 commit intomainfrom
feature/BD-2290-size-limit-for-bbd-symbol
Mar 23, 2026
Merged

feat: implement base64-aware size validation for building_block_definition symbol#136
sttomm merged 1 commit intomainfrom
feature/BD-2290-size-limit-for-bbd-symbol

Conversation

@nroi
Copy link
Copy Markdown
Contributor

@nroi nroi commented Mar 19, 2026

BD-2290
BD-2290

related PR: https://github.com/meshcloud/meshfed-release/pull/9620

I've tested it locally. A tofu plan goes through with an image that is exactly 100 KiB of size, like so:

symbol       = "data:image/svg+xml;base64,${filebase64("/path/to/svg/exactly-100kib.svg")}"

with an image that's 100 KiB plus one byte, we get this error during plan:

╷
│ Error: Symbol Image Too Large
│
│   with meshstack_building_block_definition.example_03_manual,
│   on main.tf line 27, in resource "meshstack_building_block_definition" "example_03_manual":
│   27: resource "meshstack_building_block_definition" "example_03_manual" {
│
│ The decoded symbol image is 102401 bytes, which exceeds the maximum allowed size of 100 KiB (102400 bytes).
╵

@nroi nroi force-pushed the feature/BD-2290-size-limit-for-bbd-symbol branch 4 times, most recently from b3995b2 to 8070dad Compare March 19, 2026 10:05
@nroi nroi marked this pull request as ready for review March 19, 2026 10:07
@nroi nroi requested review from Copilot and grubmeshi March 19, 2026 10:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Implements client-side validation for meshstack_building_block_definition.spec.symbol to ensure image data URIs are base64-valid and within the decoded size limit, improving early feedback in Terraform plans/applies.

Changes:

  • Added a SymbolSize string validator that accepts http(s):// URLs or whitelisted data:image/*;base64, URIs and enforces a 100 KiB decoded limit.
  • Wired the new validator into the Building Block Definition resource schema for spec.symbol.
  • Added provider tests covering valid/invalid URLs, MIME types, base64 correctness, and boundary size conditions.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
internal/validators/symbol_size_validator.go New string validator implementing base64-aware symbol validation and decoded-size enforcement.
internal/provider/building_block_definition_resource_schema.go Applies validators.SymbolSize{} to spec.symbol schema attribute.
internal/provider/building_block_definition_resource_test.go Adds test matrix for symbol validation behavior via resource test steps.

Comment thread internal/validators/symbol_size_validator.go
Comment thread internal/provider/building_block_definition_resource_test.go Outdated
Comment thread internal/provider/building_block_definition_resource_schema.go
@nroi nroi force-pushed the feature/BD-2290-size-limit-for-bbd-symbol branch 2 times, most recently from fc646b9 to 86e6e34 Compare March 19, 2026 14:05
Comment thread CHANGELOG.md Outdated
@sttomm sttomm force-pushed the feature/BD-2290-size-limit-for-bbd-symbol branch from 86e6e34 to 6a1e0a8 Compare March 23, 2026 10:36
@sttomm sttomm merged commit ba17461 into main Mar 23, 2026
4 checks passed
@sttomm sttomm deleted the feature/BD-2290-size-limit-for-bbd-symbol branch March 23, 2026 10:41
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.

4 participants