Search code examples
s4sdksap-cloud-sdk

xs-app.json/routes/0: Format validation failed (Route references unknown destination "service-destination")


trying to install the approuter currently, following this tutorial:

https://blogs.sap.com/2017/07/18/step-7-with-sap-s4hana-cloud-sdk-secure-your-application-on-sap-cloud-platform-cloudfoundry/

When pushing the approuter to CF, I get an destination error:

xs-app.json/routes/0: Format validation failed (Route references unknown destination "service-destination")

This is my manifest.yml:

---
applications:
- name: xyz
  command: 'node approuter/approuter.js'
  host: xyz-93deb1cd-7b72-4060-94e7-21342342
  path: approuter
  memory: 128M
  buildpack: https://github.com/cloudfoundry/nodejs-buildpack
  env:
    TENANT_HOST_PATTERN: 'xyz(.*).cfapps.eu10.hana.ondemand.com'
    destinations: "[{"name":"service-destination", "url": "https://gfuowbasdatq19agtuthorizations-srv.cfapps.eu10.hana.ondemand.com", "forwardAuthToken": true}]"
    SAP_JWT_TRUST_ACL: '[{"clientid" : "*", "identityzone" : "*"}]'

  services:
    - my-xsuaa
    - service-destination

This is my xs-app.json:

{
  "routes": [{
    "source": "/",
    "target": "/",
    "destination": "service-destination"
  }]
}

Where is the application actually searching for this destination? I created it in my CF-account as well, pointing to my service-url.


Solution

  • In YAML (as well as many other markup languages, e.g. JSON) double quotes inside double quotes need to be escaped. (Cf. the YAML spec section 7.3.1 and this blog post)

    So for you there are two options for your destinations variable: 1. Replacing all " inside with \" (relatively cumbersome, especially if you want to change the destinations in the future) 2. Use single quotes as boundaries. So the value of your destinations variable would look like this:

    '[{"name":"service-destination", "url": "https://gfuowbasdatq19agtuthorizations-srv.cfapps.eu10.hana.ondemand.com", "forwardAuthToken": true}]'