atsign-foundation / at_tools

Various developer tools for use when developing with Atsign's technology
https://pub.dev/publishers/atsign.org/packages
BSD 3-Clause "New" or "Revised" License
23 stars 9 forks source link

at_cli fails with unhandled exception #238

Closed ralfeus closed 1 year ago

ralfeus commented 1 year ago

Describe the bug When trying to execute any verb the following exception is thrown:

$ at_cli -v scan -a -f ~/@81bored7_key.atKeys --atsign @81bored7

Unhandled exception:
Null check operator used on a null value
#0      _getAtCliPreference (file:///Users/ralfeus/Projects/at_tools/at_cli/bin/main.dart:64)
#1      main (file:///Users/ralfeus/Projects/at_tools/at_cli/bin/main.dart:19)
#2      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295)
#3      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192)

To Reproduce Steps to reproduce the behavior:

  1. Run dart run main.dart or compiled at_cli with parameters: -v scan -a -f <key file> --atsign <your atSign>

Expected behavior List of keys to be returned

Were you using an atApplication when the bug was found? no

Additional context The scan verb is just an example. Any other verb cause same error

cpswan commented 1 year ago

@srieteja can you please take a look at this

@ralfeus thanks for the report.

cpswan commented 1 year ago

@ralfeus can you please let us know which version of Dart you're using with dart --version

It might also help if we can see your pubspec.lock contents so we know which versions of dependencies you're using.

ralfeus commented 1 year ago

Dart SDK version: 2.18.1 (stable) (Tue Sep 13 11:42:55 2022 +0200) on "macos_arm64"

pubspec.lock:

# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
  _fe_analyzer_shared:
    dependency: transitive
    description:
      name: _fe_analyzer_shared
      url: "https://pub.dartlang.org"
    source: hosted
    version: "49.0.0"
  analyzer:
    dependency: transitive
    description:
      name: analyzer
      url: "https://pub.dartlang.org"
    source: hosted
    version: "5.1.0"
  archive:
    dependency: transitive
    description:
      name: archive
      url: "https://pub.dartlang.org"
    source: hosted
    version: "3.3.1"
  args:
    dependency: "direct main"
    description:
      name: args
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.3.1"
  asn1lib:
    dependency: transitive
    description:
      name: asn1lib
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.1.1"
  async:
    dependency: transitive
    description:
      name: async
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.9.0"
  at_base2e15:
    dependency: transitive
    description:
      name: at_base2e15
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.0.0"
  at_client:
    dependency: "direct main"
    description:
      name: at_client
      url: "https://pub.dartlang.org"
    source: hosted
    version: "3.0.40"
  at_commons:
    dependency: transitive
    description:
      name: at_commons
      url: "https://pub.dartlang.org"
    source: hosted
    version: "3.0.26"
  at_lookup:
    dependency: "direct main"
    description:
      name: at_lookup
      url: "https://pub.dartlang.org"
    source: hosted
    version: "3.0.31"
  at_persistence_secondary_server:
    dependency: transitive
    description:
      name: at_persistence_secondary_server
      url: "https://pub.dartlang.org"
    source: hosted
    version: "3.0.36"
  at_persistence_spec:
    dependency: transitive
    description:
      name: at_persistence_spec
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.0.7"
  at_utf7:
    dependency: transitive
    description:
      name: at_utf7
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.0.0"
  at_utils:
    dependency: transitive
    description:
      name: at_utils
      url: "https://pub.dartlang.org"
    source: hosted
    version: "3.0.11"
  boolean_selector:
    dependency: transitive
    description:
      name: boolean_selector
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.1.0"
  clock:
    dependency: transitive
    description:
      name: clock
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.1.1"
  collection:
    dependency: transitive
    description:
      name: collection
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.16.0"
  convert:
    dependency: transitive
    description:
      name: convert
      url: "https://pub.dartlang.org"
    source: hosted
    version: "3.0.2"
  coverage:
    dependency: transitive
    description:
      name: coverage
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.6.1"
  cron:
    dependency: transitive
    description:
      name: cron
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.5.0"
  crypto:
    dependency: transitive
    description:
      name: crypto
      url: "https://pub.dartlang.org"
    source: hosted
    version: "3.0.2"
  crypton:
    dependency: "direct main"
    description:
      name: crypton
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.0.5"
  encrypt:
    dependency: "direct main"
    description:
      name: encrypt
      url: "https://pub.dartlang.org"
    source: hosted
    version: "5.0.1"
  file:
    dependency: transitive
    description:
      name: file
      url: "https://pub.dartlang.org"
    source: hosted
    version: "6.1.4"
  frontend_server_client:
    dependency: transitive
    description:
      name: frontend_server_client
      url: "https://pub.dartlang.org"
    source: hosted
    version: "3.0.0"
  glob:
    dependency: transitive
    description:
      name: glob
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.1.0"
  hive:
    dependency: transitive
    description:
      name: hive
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.2.3"
  http:
    dependency: transitive
    description:
      name: http
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.13.5"
  http_multi_server:
    dependency: transitive
    description:
      name: http_multi_server
      url: "https://pub.dartlang.org"
    source: hosted
    version: "3.2.1"
  http_parser:
    dependency: transitive
    description:
      name: http_parser
      url: "https://pub.dartlang.org"
    source: hosted
    version: "4.0.1"
  internet_connection_checker:
    dependency: transitive
    description:
      name: internet_connection_checker
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.0.1+4"
  io:
    dependency: transitive
    description:
      name: io
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.0.3"
  js:
    dependency: transitive
    description:
      name: js
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.6.4"
  lints:
    dependency: "direct dev"
    description:
      name: lints
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.0.1"
  logging:
    dependency: transitive
    description:
      name: logging
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.0.2"
  matcher:
    dependency: transitive
    description:
      name: matcher
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.12.12"
  meta:
    dependency: transitive
    description:
      name: meta
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.8.0"
  mime:
    dependency: transitive
    description:
      name: mime
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.0.2"
  mocktail:
    dependency: transitive
    description:
      name: mocktail
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.3.0"
  mutex:
    dependency: transitive
    description:
      name: mutex
      url: "https://pub.dartlang.org"
    source: hosted
    version: "3.0.0"
  node_preamble:
    dependency: transitive
    description:
      name: node_preamble
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.0.1"
  package_config:
    dependency: transitive
    description:
      name: package_config
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.1.0"
  path:
    dependency: transitive
    description:
      name: path
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.8.2"
  pointycastle:
    dependency: transitive
    description:
      name: pointycastle
      url: "https://pub.dartlang.org"
    source: hosted
    version: "3.6.2"
  pool:
    dependency: transitive
    description:
      name: pool
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.5.1"
  pub_semver:
    dependency: transitive
    description:
      name: pub_semver
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.1.1"
  shelf:
    dependency: transitive
    description:
      name: shelf
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.4.0"
  shelf_packages_handler:
    dependency: transitive
    description:
      name: shelf_packages_handler
      url: "https://pub.dartlang.org"
    source: hosted
    version: "3.0.1"
  shelf_static:
    dependency: transitive
    description:
      name: shelf_static
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.1.1"
  shelf_web_socket:
    dependency: transitive
    description:
      name: shelf_web_socket
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.0.2"
  source_map_stack_trace:
    dependency: transitive
    description:
      name: source_map_stack_trace
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.1.0"
  source_maps:
    dependency: transitive
    description:
      name: source_maps
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.10.10"
  source_span:
    dependency: transitive
    description:
      name: source_span
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.9.1"
  stack_trace:
    dependency: transitive
    description:
      name: stack_trace
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.10.0"
  stream_channel:
    dependency: transitive
    description:
      name: stream_channel
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.1.1"
  string_scanner:
    dependency: transitive
    description:
      name: string_scanner
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.1.1"
  term_glyph:
    dependency: transitive
    description:
      name: term_glyph
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.2.1"
  test:
    dependency: "direct dev"
    description:
      name: test
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.21.6"
  test_api:
    dependency: transitive
    description:
      name: test_api
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.4.14"
  test_core:
    dependency: transitive
    description:
      name: test_core
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.4.18"
  test_process:
    dependency: "direct dev"
    description:
      name: test_process
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.0.2"
  typed_data:
    dependency: transitive
    description:
      name: typed_data
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.3.1"
  uuid:
    dependency: transitive
    description:
      name: uuid
      url: "https://pub.dartlang.org"
    source: hosted
    version: "3.0.6"
  vm_service:
    dependency: transitive
    description:
      name: vm_service
      url: "https://pub.dartlang.org"
    source: hosted
    version: "9.4.0"
  watcher:
    dependency: transitive
    description:
      name: watcher
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.0.1"
  web_socket_channel:
    dependency: transitive
    description:
      name: web_socket_channel
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.2.0"
  webkit_inspection_protocol:
    dependency: transitive
    description:
      name: webkit_inspection_protocol
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.2.0"
  yaml:
    dependency: transitive
    description:
      name: yaml
      url: "https://pub.dartlang.org"
    source: hosted
    version: "3.1.1"
sdks:
  dart: ">=2.18.0 <3.0.0"
cpswan commented 1 year ago

Thanks @ralfeus

To set expectations, it's a holiday (and getting late already in their time zone) for the engineer I asked to look at this, so it's likely to be tomorrow before we get to investigate.

ralfeus commented 1 year ago

No rush. I can live without it

srieteja commented 1 year ago

@ralfeus I just pushed a fix for the issue mentioned into trunk. If you could re-compile the program and run it, it should resolve the issue you're facing.

ralfeus commented 1 year ago

That works now. Thanks!

ralfeus commented 1 year ago

Same issue occurs when I run at_cli from other directory than at_tools/at_cli/bin. I have at_cli added to PATH and want to run from anywhere. But if I run it from any other place but one above I get:

Unhandled exception:
Null check operator used on a null value
#0      _getAtCliPreference (file:///Users/ralfeus/Projects/at_tools/at_cli/bin/main.dart:64)
#1      main (file:///Users/ralfeus/Projects/at_tools/at_cli/bin/main.dart:19)
#2      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295)
#3      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192)
srieteja commented 1 year ago

@ralfeus I reworked the parts of the code that extract the data from config.yaml. I've tested and merged it to trunk, I can now run the at_cli binary from anywhere in my Linux and it works as expected. Please try out the new code; it should resolve your issue.

ralfeus commented 1 year ago

Thanks for the update. I've pulled new changes and now I get following error:

Unhandled exception:
Exception: Could not find package location
#0      ConfigUtil._getConfigFile (package:at_cli/src/config_util.dart:24)
<asynchronous suspension>
#1      ConfigUtil.init (package:at_cli/src/config_util.dart:12)
<asynchronous suspension>
#2      main (file:///Users/ralfeus/Projects/at_tools/at_cli/bin/main.dart:11)
<asynchronous suspension>
Expecting value: line 1 column 1 (char 0)
srieteja commented 1 year ago

This looks like a platform-related error. The dart:isolate based changes might not be working as expected on mac. Let me quickly look into that.

srieteja commented 1 year ago

We came up with a different approach this time, that overcomes the issue you're facing @ralfeus. Instead of trying to determine the location of the package/config.yaml during runtime; the config yaml is now generated in the home directory at a specified location which is "HOME_DIR/.atsign/at_cli/config.yaml". You can pull the changes from trunk and check it out; hopefully, it should be a smooth road ahead.

ralfeus commented 1 year ago

Now it works fine from everywhere. Thank you