X_SAML_METADATA_INVALID
Means
saml IdP metadata has no entity id, HTTP-Redirect sign-on endpoint or signing certificate
Typical cause
the metadata XML was truncated, is SP metadata rather than IdP metadata, or names only an HTTP-POST sign-on endpoint
Fix
download the IdP metadata again from its federation metadata URL and pass the whole XML to samlIdentityProvider({ metadata })