Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error "Cannot read property 'type' of undefined" when redirect to url in routes.yaml #174

Open
philltran opened this issue Sep 13, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@philltran
Copy link

Tell us about your setup
Lando v3.6.5 on macOS 12.5.1 Apple Silicon with Rosetta

Tell us about your .lando.yml

name: wordpress-site
recipe: platformsh
config:
 id: xxxxxxxxxxxxxxx
tooling:
 wp:
   service: app

Contents of ./.platform/routes.yaml:

"https://www.{default}/":
   type: upstream
   upstream: "app:http"
   cache:
       enabled: true
       # Base the cache on the session cookies. Ignore all other cookies.
       cookies:
           - '/^wordpress_logged_in_/'
           - '/^wordpress_sec_/'
           - 'wordpress_test_cookie'
           - '/^wp-settings-/'
           - '/^wp-postpass/'
"http://{default}/":
   type: redirect
   to: "https://www.{default}/"
"https://{default}/":
   type: redirect
   to: "https://www.{default}/"
"http://www.{default}/someurl/":
   type: redirect
   to: "https://www.{default}/new/url/"

Contents of .platform.app.yaml:

# This file describes an application. You can have multiple applications
# in the same project.

# The name of this app. Must be unique within a project.
name: app

# The runtime the application uses.
type: "php:7.4"

# Configuration of the build of the application.
build:
    flavor: composer

dependencies:
    php:
        composer/composer: '^2'
        wp-cli/wp-cli-bundle: "^2.4.0"

hooks:
    build: |
        set -e
        # Copy manually-provided plugins into the plugins directory.
        # This allows manually-provided and composer-provided plugins to coexist.
        rsync -a plugins/* wordpress/wp-content/plugins/

# The relationships of the application with services or other applications.
# The left-hand side is the name of the relationship as it will be exposed
# to the application in the PLATFORM_RELATIONSHIPS variable. The right-hand
# side is in the form `<service name>:<endpoint name>`.
relationships:
    database: "db:mysql"

# The configuration of app when it is exposed to the web.
web:
    locations:
        "/":
            # The public directory of the app, relative to its root.
            root: "wordpress"
            # The front-controller script to send non-static requests to.
            passthru: "/index.php"
            # Wordpress has multiple roots (wp-admin) so the following is required
            index:
                - "index.php"
            # The number of seconds whitelisted (static) content should be cached.
            expires: 600
            scripts: true
            allow: true
            rules:
                ^/composer\.json:
                    allow: false
                ^/license\.txt$:
                    allow: false
                ^/readme\.html$:
                    allow: false
        "/wp-content/cache":
            root: "wordpress/wp-content/cache"
            scripts: false
            allow: false
        "/wp-content/uploads":
            root: "wordpress/wp-content/uploads"
            scripts: false
            allow: true

# The size of the persistent disk of the application (in MB).
disk: 4096

# The mounts that will be performed when the package is deployed.
mounts:
    "wordpress/wp-content/cache":
        source: local
        source_path: "cache"
    "wordpress/wp-content/uploads":
        source: local
        source_path: "uploads"

source:
  operations:
    auto-update:
      command: |
        curl -fsS https://raw.githubusercontent.com/platformsh/source-operations/main/setup.sh | { bash /dev/fd/3 sop-autoupdate; } 3<&0

crons:
    snapshot:
        # Take a snapshot automatically every night at 3 am (UTC).
        spec: '0 3 * * *'
        cmd: |
            platform backup:create --yes --no-wait

Tell us about the command you were running
Starting or rebuilding environment

lando start
lando rebuild -y -vv

Unhandled rejection TypeError: Cannot read property 'type' of undefined
   at getUpstream (/snapshot/cli/node_modules/@lando/platformsh/lib/proxy.js)
   at /snapshot/cli/node_modules/@lando/platformsh/lib/proxy.js
   at arrayMap (/snapshot/cli/node_modules/lodash/lodash.js:653:23)
   at Function.map (/snapshot/cli/node_modules/lodash/lodash.js:9622:14)
   at interceptor (/snapshot/cli/node_modules/lodash/lodash.js:17094:35)
   at thru (/snapshot/cli/node_modules/lodash/lodash.js:8859:14)
   at /snapshot/cli/node_modules/lodash/lodash.js:4430:28
   at arrayReduce (/snapshot/cli/node_modules/lodash/lodash.js:697:21)
   at baseWrapperValue (/snapshot/cli/node_modules/lodash/lodash.js:4429:14)
   at LazyWrapper.lazyValue [as value] (/snapshot/cli/node_modules/lodash/lodash.js:1901:16)
   at baseWrapperValue (/snapshot/cli/node_modules/lodash/lodash.js:4427:25)
   at LodashWrapper.wrapperValue (/snapshot/cli/node_modules/lodash/lodash.js:9114:14)
   at /snapshot/cli/node_modules/@lando/platformsh/lib/proxy.js
   at new LandoPlatformsh (/snapshot/cli/node_modules/@lando/platformsh/recipes/platformsh/builder.js)
   at AsyncEvents.<anonymous> (/snapshot/cli/plugins/lando-recipes/app.js)
   at AsyncEvents.handle (/snapshot/cli/lib/events.js)
From previous event:
   at AsyncEvents.emit (/snapshot/cli/lib/events.js)
   at /snapshot/cli/lib/app.js
From previous event:
   at App.init (/snapshot/cli/lib/app.js)
   at /snapshot/cli/bin/lando.js
From previous event:
   at Object.<anonymous> (/snapshot/cli/bin/lando.js)
   at Module._compile (pkg/prelude/bootstrap.js:1887:22)
   at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
   at Module.load (internal/modules/cjs/loader.js:950:32)
   at Function.Module._load (internal/modules/cjs/loader.js:790:12)
   at Function.runMain (pkg/prelude/bootstrap.js:1940:12)
   at internal/main/run_main_module.js:17:47

Removing redirect from routes.yaml results in successful build

"http://www.{default}/someurl/":
   type: redirect
   to: "https://www.{default}/new/url/"
@philltran philltran added the bug Something isn't working label Sep 13, 2022
@davearch
Copy link

I can confirm this exact same issue on my apple silicon macbook. Whereas other repos spin up just fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants