Skip to content

Fix GLPI 11 compatibility with current Metabase API versions - #150

Open
whamulti wants to merge 3 commits into
pluginsGLPI:mainfrom
whamulti:fix/glpi11-metabase-compat-and-embed
Open

whamulti wants to merge 3 commits into
pluginsGLPI:mainfrom
whamulti:fix/glpi11-metabase-compat-and-embed

Conversation

@whamulti

Copy link
Copy Markdown

Fixes #148

Adds backward-compatible ?? fallbacks for a handful of Metabase API fields that got renamed in current versions (ordered_cardsdashcards, sizeX/sizeYsize_x/size_y, and the new MBQL 5 dataset_query.stages[0].* shape for native questions), plus the root-collection collection_id normalization described in the issue.

Also fixes the more severe regression from 1.4.2: the embedded_token upgrade migration sets is_embedded_token_encrypted=1 without ever actually encrypting the existing plain-text value, so dashboard.class.php's unconditional GLPIKey()->decrypt() call returns an empty string and the JWT signer throws InvalidKeyProvided on every visit to the embedded dashboard tab. Fixed to actually encrypt, mirroring the password migration right above it.

All of this has been running in production against a live Metabase v0.63.2 instance for a few days now (both the extraction features and the embedded dashboard), see the issue for full repro steps and context. Happy to adjust anything if you'd prefer a different approach.

Several API response fields the plugin reads under their old names
were renamed by Metabase, and the newer native-question query format
("MBQL 5") wasn't handled at all:

- ordered_cards -> dashcards on GET /api/dashboard/:id
- sizeX/sizeY -> size_x/size_y on dashboard cards
- dataset_query.native.{query,template-tags} moved to
  dataset_query.stages[0].{native,template-tags}
- getCards('root') never matched cards in the root collection, since
  the API returns id:"root" for that collection but collection_id:null
  on the cards themselves

All fixed with backward-compatible `??` fallbacks so older Metabase
instances keep working.

Also fixes a more severe regression introduced in 1.4.2: embedded_token
was added to secured_configs and is expected to be sodium-encrypted,
but the upgrade migration only flipped the is_embedded_token_encrypted
flag without ever actually encrypting the existing plain-text value.
dashboard.class.php unconditionally decrypts embedded_token before
signing the dashboard JWT, so any site that already had a token
configured before upgrading got an empty signing key and an uncaught
Lcobucci\JWT\Signer\InvalidKeyProvided exception on every visit to the
embedded dashboard tab. The migration now actually encrypts the value,
mirroring what the password migration a few lines above already does.

Fixes pluginsGLPI#148
Comment thread inc/config.class.php
@stonebuzz

Copy link
Copy Markdown
Contributor

Can you adapt CHANGELOG.md ?

Rom1-B
Rom1-B previously requested changes Aug 17, 2026

@Rom1-B Rom1-B left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please update CHANGELOG

Comment thread inc/config.class.php
@whamulti

Copy link
Copy Markdown
Author

Added the CHANGELOG entry as requested. Also replied inline to the double-encryption question with a concrete trace through Plugin::install() / plugin_init_metabase() and a live test confirming the secured_configs hook isn't registered during that migration step (plugin is necessarily inactive at that point), so the explicit encrypt() call is needed there. Let me know if there's anything else you'd like changed - happy to adjust.

@stonebuzz
stonebuzz requested review from Rom1-B and stonebuzz August 28, 2026 13:59
@stonebuzz
stonebuzz dismissed Rom1-B’s stale review August 28, 2026 14:00

Already done

Comment thread CHANGELOG.md Outdated
Comment on lines +12 to +15
- Fix question/dashboard extraction against current Metabase API versions (`ordered_cards` → `dashcards`, `sizeX`/`sizeY` → `size_x`/`size_y`, native question query moved to `dataset_query.stages[0].*`)
- Fix root collection questions never matching in `getCards('root')`
- Fix extraction AJAX URL resolving to the wrong host when `root_doc` is empty
- Fix `embedded_token` migration not actually encrypting the value on upgrade, breaking the embedded dashboard with an `InvalidKeyProvided` exception for any site that had a token configured before updating to 1.4.2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
- Fix question/dashboard extraction against current Metabase API versions (`ordered_cards``dashcards`, `sizeX`/`sizeY``size_x`/`size_y`, native question query moved to `dataset_query.stages[0].*`)
- Fix root collection questions never matching in `getCards('root')`
- Fix extraction AJAX URL resolving to the wrong host when `root_doc` is empty
- Fix `embedded_token` migration not actually encrypting the value on upgrade, breaking the embedded dashboard with an `InvalidKeyProvided` exception for any site that had a token configured before updating to 1.4.2
- Fixed Metabase compatibility with current API versions
- Fix `embedded-token` migration for existing configurations.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(last change)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Applied, thanks for confirming the encryption discussion too!

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.

"Metabase 1.4.2 breaks on GLPI 11: unhandled API renames break extraction, and a broken migration breaks the embedded dashboard entirely"

3 participants