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

compose.yml parser issue #1139

Open
landsman opened this issue Feb 8, 2025 · 0 comments
Open

compose.yml parser issue #1139

landsman opened this issue Feb 8, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@landsman
Copy link

landsman commented Feb 8, 2025

Describe the bug

Script breaks on some typo in compose.yml

To Reproduce

use this wrong compose file:

services:
  web:
    build: .
    ports:
      - "8000:80"
    volumes:
      - .:/var/www/html
    depends_on:exit
      - db
  db:
    image: postgres:12.14-alpine
    environment:
      POSTGRES_DB: postgres
      POSTGRES_USER: simu
      POSTGRES_PASSWORD: test
    volumes:
      - pgdata:/var/lib/postgresql/data
  node:
    image: node:16
    working_dir: /var/www/html
    volumes:
      - .:/var/www/html
    command: sleep infinity

volumes:
  pgdata:

Expected behavior

Do not print trackeback, just the incorrect line in the file.

Actual behavior

podman-compose -f compose.yml --build
usage: podman-compose [-h] [-v] [--in-pod in_pod] [--pod-args pod_args] [--env-file env_file] [-f file] [--profile profile] [-p PROJECT_NAME] [--podman-path PODMAN_PATH] [--podman-args args]
                      [--podman-pull-args args] [--podman-push-args args] [--podman-build-args args] [--podman-inspect-args args] [--podman-run-args args] [--podman-start-args args]
                      [--podman-stop-args args] [--podman-rm-args args] [--podman-volume-args args] [--no-ansi] [--no-cleanup] [--dry-run] [--parallel PARALLEL] [--verbose]
                      {help,version,wait,systemd,pull,push,build,up,down,ps,run,exec,start,stop,restart,logs,config,port,pause,unpause,kill,stats,images} ...
podman-compose: error: unrecognized arguments: --build
landsman@m2 simuportfolio % podman-compose -f compose.yml up --build
Traceback (most recent call last):
  File "/opt/homebrew/bin/podman-compose", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/opt/homebrew/Cellar/podman-compose/1.3.0/libexec/lib/python3.13/site-packages/podman_compose.py", line 3711, in main
    asyncio.run(async_main())
    ~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/base_events.py", line 720, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/opt/homebrew/Cellar/podman-compose/1.3.0/libexec/lib/python3.13/site-packages/podman_compose.py", line 3707, in async_main
    await podman_compose.run()
  File "/opt/homebrew/Cellar/podman-compose/1.3.0/libexec/lib/python3.13/site-packages/podman_compose.py", line 1859, in run
    self._parse_compose_file()
    ~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/opt/homebrew/Cellar/podman-compose/1.3.0/libexec/lib/python3.13/site-packages/podman_compose.py", line 1955, in _parse_compose_file
    content = yaml.safe_load(f)
  File "/opt/homebrew/Cellar/podman-compose/1.3.0/libexec/lib/python3.13/site-packages/yaml/__init__.py", line 125, in safe_load
    return load(stream, SafeLoader)
  File "/opt/homebrew/Cellar/podman-compose/1.3.0/libexec/lib/python3.13/site-packages/yaml/__init__.py", line 81, in load
    return loader.get_single_data()
           ~~~~~~~~~~~~~~~~~~~~~~^^
  File "/opt/homebrew/Cellar/podman-compose/1.3.0/libexec/lib/python3.13/site-packages/yaml/constructor.py", line 49, in get_single_data
    node = self.get_single_node()
  File "/opt/homebrew/Cellar/podman-compose/1.3.0/libexec/lib/python3.13/site-packages/yaml/composer.py", line 36, in get_single_node
    document = self.compose_document()
  File "/opt/homebrew/Cellar/podman-compose/1.3.0/libexec/lib/python3.13/site-packages/yaml/composer.py", line 55, in compose_document
    node = self.compose_node(None, None)
  File "/opt/homebrew/Cellar/podman-compose/1.3.0/libexec/lib/python3.13/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/opt/homebrew/Cellar/podman-compose/1.3.0/libexec/lib/python3.13/site-packages/yaml/composer.py", line 133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  File "/opt/homebrew/Cellar/podman-compose/1.3.0/libexec/lib/python3.13/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/opt/homebrew/Cellar/podman-compose/1.3.0/libexec/lib/python3.13/site-packages/yaml/composer.py", line 133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  File "/opt/homebrew/Cellar/podman-compose/1.3.0/libexec/lib/python3.13/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/opt/homebrew/Cellar/podman-compose/1.3.0/libexec/lib/python3.13/site-packages/yaml/composer.py", line 133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  File "/opt/homebrew/Cellar/podman-compose/1.3.0/libexec/lib/python3.13/site-packages/yaml/composer.py", line 82, in compose_node
    node = self.compose_sequence_node(anchor)
  File "/opt/homebrew/Cellar/podman-compose/1.3.0/libexec/lib/python3.13/site-packages/yaml/composer.py", line 110, in compose_sequence_node
    while not self.check_event(SequenceEndEvent):
              ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/podman-compose/1.3.0/libexec/lib/python3.13/site-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
                         ~~~~~~~~~~^^
  File "/opt/homebrew/Cellar/podman-compose/1.3.0/libexec/lib/python3.13/site-packages/yaml/parser.py", line 382, in parse_block_sequence_entry
    if self.check_token(BlockEntryToken):
       ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/podman-compose/1.3.0/libexec/lib/python3.13/site-packages/yaml/scanner.py", line 115, in check_token
    while self.need_more_tokens():
          ~~~~~~~~~~~~~~~~~~~~~^^
  File "/opt/homebrew/Cellar/podman-compose/1.3.0/libexec/lib/python3.13/site-packages/yaml/scanner.py", line 152, in need_more_tokens
    self.stale_possible_simple_keys()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/opt/homebrew/Cellar/podman-compose/1.3.0/libexec/lib/python3.13/site-packages/yaml/scanner.py", line 291, in stale_possible_simple_keys
    raise ScannerError("while scanning a simple key", key.mark,
            "could not find expected ':'", self.get_mark())
yaml.scanner.ScannerError: while scanning a simple key
  in "compose.yml", line 8, column 5
could not find expected ':'
  in "compose.yml", line 10, column 3

Environment:

  • OS: Mac
  • podman version: 5.3.2
  • podman compose version: 1.3.0
@landsman landsman added the bug Something isn't working label Feb 8, 2025
@landsman landsman changed the title unsupported parameter show up traceback compose.yml parser issue Feb 8, 2025
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

1 participant