fermyon / cloud-plugin

A Spin plugin for the Spin CLI for managing Spin apps in Fermyon Cloud.
https://developer.fermyon.com/cloud/
Apache License 2.0
8 stars 13 forks source link

index out of bounds on running `spin cloud apps info <APP>` #183

Closed dfntlynotjorn closed 8 months ago

dfntlynotjorn commented 8 months ago
$ spin --version
spin 2.3.1 (22c2ac5 2024-03-07)
$ spin clouds --version
spin-cloud 0.7.0 (0519939 2024-01-31)
$ spin cloud apps info site
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', src/commands/apps.rs:107:23
stack backtrace:
   0:        0x10f9e91b3 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h574028a0687b01b1
   1:        0x10fa0d5eb - core::fmt::write::hc3a291ca045d4386
   2:        0x10f9e4648 - std::io::Write::write_fmt::hce33c3aef899c477
   3:        0x10f9e8faa - std::sys_common::backtrace::print::hec404ce64d885bc1
   4:        0x10f9eaa15 - std::panicking::default_hook::{{closure}}::hb702376be934f723
   5:        0x10f9ea81f - std::panicking::default_hook::he55b66a35bee68d8
   6:        0x10f9eaeb3 - std::panicking::rust_panic_with_hook::hcabbae61abda3f7a
   7:        0x10f9eadd3 - std::panicking::begin_panic_handler::{{closure}}::hb0d2e10207b82ddc
   8:        0x10f9e95b9 - std::sys_common::backtrace::__rust_end_short_backtrace::h3fbd78d34f010841
   9:        0x10f9eab0d - _rust_begin_unwind
  10:        0x10fa44d43 - core::panicking::panic_fmt::heecc6c3994a0556d
  11:        0x10fa44e96 - core::panicking::panic_bounds_check::h8344f24acc965f7a
  12:        0x10f315f60 - cloud_plugin::commands::apps::domains_current_and_in_progress::hd4e7090418a2a8cb
  13:        0x10f3e0248 - cloud_plugin::main::{{closure}}::ha3ce8fe3f1720ae7
  14:        0x10f39a6f0 - tokio::runtime::park::CachedParkThread::block_on::h99a5869f2881176f
  15:        0x10f2488ab - tokio::runtime::context::runtime::enter_runtime::h2e5a02e4f3903e89
  16:        0x10f28ddbf - tokio::runtime::runtime::Runtime::block_on::hde5100de5a40de57
  17:        0x10f317a17 - cloud_plugin::main::hb35521563f24e276
  18:        0x10f3828a6 - std::sys_common::backtrace::__rust_begin_short_backtrace::h9bc2a3fbef9e8503
  19:        0x10f3829b1 - std::rt::lang_start::{{closure}}::h1532a215728f63ce
  20:        0x10f9ddc7a - std::rt::lang_start_internal::h35bfd4814712c868
  21:        0x10f317afc - _main
vdice commented 8 months ago

Thanks for filing. I can repro this on at least one of my apps as well. Definitely appears to be domain-related (looking at cloud_plugin::commands::apps::domains_current_and_in_progress::hd4e7090418a2a8cb from the stack trace). In fact, it has been awhile since I last deployed/configured this app, but I believe I did at one point configure a custom domain, or had attempted configuration of one.

vdice commented 8 months ago

Well, I appear to have hit it with a freshly-deployed app, so scratch my impression that it only affects apps w/ custom domain configuration:

$ spin cloud apps info new-rust
Warning: You're using a pre-release version of Spin (2.4.0-pre0). This plugin might not be compatible (supported: >=1.3). Continuing anyway.
thread 'main' panicked at src/commands/apps.rs:107:35:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
   0: rust_begin_unwind
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:72:14
   2: core::panicking::panic_bounds_check
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:208:5
   3: cloud_plugin::commands::apps::domains_current_and_in_progress
   4: cloud_plugin::main::{{closure}}
   5: tokio::runtime::park::CachedParkThread::block_on
   6: tokio::runtime::context::runtime::enter_runtime
   7: tokio::runtime::runtime::Runtime::block_on
   8: cloud_plugin::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Stemming from the following line in apps.rs

itowlson commented 8 months ago

That implies there are no channels for the app - I thought there was always exactly one channel. @bacongobbler any idea why that might be?

bacongobbler commented 8 months ago

I thought there was always exactly one channel

This used to be the case. Nowadays apps are created without a channel.

Looks like spin cloud apps info relies on the app having at least one channel to fetch the "app subdomain". This can now be fetched through the subdomain field. #185 addresses this.

I'll go check and see if there are other locations in the cloud plugin that are still relying on one channel being required.

bacongobbler commented 8 months ago

I checked and this appears to be the only location requiring the use of channels.

Thanks for identifying this issue, @dfntlynotjorn!

bacongobbler commented 8 months ago

We've pushed a fix and released it under v0.7.1. You can fetch the latest release by calling spin plugins update && spin plugins upgrade.

Thanks again for the report!