Question

Updating App Spec via doctl vs. Control Panel - ERROR PARSING

Posted June 25, 2021 362 views
DigitalOcean API and CLI (doctl)DigitalOcean App Platform

I am trying to provide the app-spec for each deployment via the doctl apps update <app-id> --spec app-production.yml command.

This way I was trying to solve following behaviour:

  • We manually set the cors settings in the app.yml and upload it in the control panel
  • We change the Environment variables via the control panels directly
  • The cors settings are lost and the app.yml seems to be “resetted”

By providing the app.yml during the CI pipeline I was trying to avoid inconsistencies or unexpected behaviour.

However, when I download the spec from the control panel (the exact same spec that is working and deployed) and try to provide it via the doctl apps update command it fails with:

Error: parsing app spec: json: unknown field "allow_headers"

The spec looks roughly like this:

databases:
- engine: PG
  name: db
  num_nodes: 1
  size: db-s-dev-database
  version: "12"
domains:
- domain: XXX
  type: PRIMARY
  zone: XXX 
name: core
region: fra
services:
- cors:
    allow_headers:
    - '*'
    allow_methods:
    - GET
    - OPTIONS
    - POST
    - PUT
    - PATCH
    - DELETE
    allow_origins:
    - exact: YXZ
  envs:
  - key: DATABASE_URL
    scope: RUN_TIME
    value: ${db.DATABASE_URL}
  - key: DB_HOST
    scope: RUN_AND_BUILD_TIME
    value: XXX
  - key: DB_PORT
    scope: RUN_AND_BUILD_TIME
    value: "25060"
  - key: DB_USER
    scope: RUN_AND_BUILD_TIME
    value: db
  - key: DB_PASSWORD
    scope: RUN_AND_BUILD_TIME
    value: XXX
  - key: DB_DATABASE
    scope: RUN_AND_BUILD_TIME
    value: db
  - key: DB_SSL
    scope: RUN_AND_BUILD_TIME
    value: "yes"
  - key: SENDING_MAIL
    scope: RUN_AND_BUILD_TIME
    value: XXX
  - key: RECEIVING_MAIL
    scope: RUN_AND_BUILD_TIME
    value: XXX
  - key: SECRET
    scope: RUN_AND_BUILD_TIME
    value: XXX
  http_port: 80
  image:
    registry_type: DOCR
    repository: core
    tag: latest
  instance_count: 1
  instance_size_slug: basic-xs
  name: core
  routes:
  - path: /
  run_command: bash -c "uvicorn api:app --host 0.0.0.0 --port 80"

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
2 answers

Hi @WazzMaxx,

What version of doctl are you using? Support for the new CORS policy fields was only added in the most recent release, v1.61.0.

 $ doctl version
doctl version 1.61.0-release
Git commit hash: c46d9619
  • That explains alot and solves the problem. Stupid me even shortly thought about updating doctl

    Thanks for the fast response!

    I was on 1.60.0

    • No problem. Glad it’s working!

      • Nonetheless, the first behaviour is still confusing and caused our application to be unavailable a couple of times:

        This way I was trying to solve following behaviour:
        
        - We manually set the cors settings in the app.yml and upload it in the control panel
        - We change the Environment variables via the control panels directly (not via the app.yml) 
        - The cors settings are lost and the app.yml seems to be “resetted”
        
        

Naturally, I am wondering: How can it be that a spec that I am using in the control panel (and that is obviously working) does not pass the parsing stage of the command line?
Thanks in advance for your efforts, suggestions and answers :)