Skip to content

/commit API returns 500 error if body is empty #26261

Closed
@richvdh

Description

@richvdh

Issue Description

The /commit REST API returns a 500 error, unless the body is non-empty:

$ curl --unix-socket $XDG_RUNTIME_DIR/podman/podman.sock -H content-type:application/json  -X POST http://d/v4.0.0/commit?container=test 
{"cause":"EOF","message":"Decode(): EOF","response":500}

Adding a JSON body makes the request succeed:

$ curl --unix-socket $XDG_RUNTIME_DIR/podman/podman.sock -H content-type:application/json  -X POST http://d/v4.0.0/commit?container=test -d {}
{"Id":"fcc42045bb0d9ce8f8f3a56a402bd5b5cc3c2b1bcc3e11ace7452fc12df49e6e"}

[Tested on v4.3.1. Apologies if this is already fixed in more recent versions; I couldn't easily figure out a way to install a later version.]

Steps to reproduce the issue

Steps to reproduce the issue

  1. Spin up a container
  2. Try to turn it into an image with the /commit API (curl --unix-socket $XDG_RUNTIME_DIR/podman/podman.sock -H content-type:application/json -X POST http://d/v4.0.0/commit?container=test

Describe the results you received

500 error

Describe the results you expected

New image created

podman info output

host:
  arch: amd64
  buildahVersion: 1.28.2
  cgroupControllers:
  - cpu
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon_2.1.6+ds1-1_amd64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.6, commit: unknown'
  cpuUtilization:
    idlePercent: 94.71
    systemPercent: 0.69
    userPercent: 4.61
  cpus: 16
  distribution:
    codename: bookworm
    distribution: debian
    version: "12"
  eventLogger: journald
  hostname: xps9320
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
  kernel: 6.12.12+bpo-amd64
  linkmode: dynamic
  logDriver: journald
  memFree: 1293332480
  memTotal: 33247899648
  networkBackend: netavark
  ociRuntime:
    name: crun
    package: crun_1.8.1-1+deb12u1_amd64
    path: /usr/bin/crun
    version: |-
      crun version 1.8.1
      commit: f8a096be060b22ccd3d5f3ebe44108517fbf6c30
      rundir: /run/user/1000/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +YAJL
  os: linux
  remoteSocket:
    exists: true
    path: /run/user/1000/podman/podman.sock
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: false
  serviceIsRemote: false
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns_1.2.0-1_amd64
    version: |-
      slirp4netns version 1.2.0
      commit: 656041d45cfca7a4176f6b7eed9e4fe6c11e8383
      libslirp: 4.7.0
      SLIRP_CONFIG_VERSION_MAX: 4
      libseccomp: 2.5.4
  swapFree: 14818500608
  swapTotal: 22884118528
  uptime: 422h 11m 47.00s (Approximately 17.58 days)
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  volume:
  - local
registries: {}
store:
  configFile: /home/rav/.config/containers/storage.conf
  containerStore:
    number: 4
    paused: 0
    running: 2
    stopped: 2
  graphDriverName: vfs
  graphOptions: {}
  graphRoot: /home/rav/.local/share/containers/storage
  graphRootAllocated: 527297863680
  graphRootUsed: 369107423232
  graphStatus: {}
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 8
  runRoot: /run/user/1000/containers
  volumePath: /home/rav/.local/share/containers/storage/volumes
version:
  APIVersion: 4.3.1
  Built: 0
  BuiltTime: Thu Jan  1 01:00:00 1970
  GitCommit: ""
  GoVersion: go1.19.8
  Os: linux
  OsArch: linux/amd64
  Version: 4.3.1

Podman in a container

No

Privileged Or Rootless

Rootless

Upstream Latest Release

No

Additional environment details

No response

Additional information

No response

Metadata

Metadata

Assignees

Labels

kind/bugCategorizes issue or PR as related to a bug.needs-infoNeed info from reportertriagedIssue has been triaged

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions