Skip to content

fix: validate CraftEngine block ID format in fromMap at config-load time#517

Merged
tastybento merged 2 commits intodevelopfrom
copilot/sub-pr-515
May 3, 2026
Merged

fix: validate CraftEngine block ID format in fromMap at config-load time#517
tastybento merged 2 commits intodevelopfrom
copilot/sub-pr-515

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 3, 2026

CraftEngineCustomBlock.fromMap() silently accepted blank strings and non-String values (coerced via Objects.toString) as valid block IDs, deferring failures to runtime placement.

Changes

  • CraftEngineCustomBlock.fromMap() — replaces Objects.toString coercion with an instanceof String pattern match; rejects blank strings and IDs that don't satisfy namespace:key format
  • isValidNamespacedKey(String) — new package-private helper; validates format without touching the CraftEngine block registry (preserving the startup timing fix from Fix false "Bad custom block" errors for CraftEngine blocks on startup #511)
// Previously accepted silently — now rejected at load time:
map.put("id", "");          // blank string
map.put("id", 42);          // non-String coerced via Objects.toString
map.put("id", "nocolon");   // missing namespace separator
map.put("id", ":key");      // empty namespace
map.put("id", "ns:");       // empty key

// Still accepted (and no registry check at load time):
map.put("id", "oneblock:common_loot_block");
  • CraftEngineCustomBlockTest — added test cases for all new rejection paths and direct coverage of isValidNamespacedKey

Copilot AI changed the title [WIP] [WIP] Address feedback from review on Release 1.25.0 pull request fix: validate CraftEngine block ID format in fromMap at config-load time May 3, 2026
Copilot AI requested a review from tastybento May 3, 2026 02:02
@tastybento tastybento marked this pull request as ready for review May 3, 2026 02:07
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 3, 2026

@tastybento tastybento merged commit f5d3558 into develop May 3, 2026
3 checks passed
@tastybento tastybento deleted the copilot/sub-pr-515 branch May 3, 2026 03:20
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.

2 participants