Skip to content

[BUG]Container crashes on startup with Missing apple_id field when no session exists #482

Description

@inboxcda

🐛 Container crashes on startup with Missing apple_id field when no session exists

📝 Description

When running mandarons/icloud-docker, the container consistently crashes during startup authentication with the following error:

P.s. Thank you for all your work on this. When it worked/works... I loved it!

icloudpy.exceptions.ICloudPyFailedLoginException:
('Invalid authentication token.', ICloudPyAPIResponseException('Missing apple_id field'))

This happens even in a completely clean environment where no session file exists.

The logs show:

Session file does not exist
Missing apple_id field
Invalid authentication token

🔁 Steps to reproduce

  1. Use a fresh Docker setup with persistent volumes:
volumes:
  - /config:/config
  - /icloud:/icloud
  1. Configure credentials:
app:
  credentials:
    username: "your_apple_id@email.com"
  1. Ensure no prior session exists:
rm -rf /config/session_data
rm -rf /home/abc/.local/*
  1. Start the container:
docker compose up

❌ Actual behavior

The container crashes immediately and loops:

Session file does not exist
Missing apple_id field
Invalid authentication token

The process restarts continuously.


✅ Expected behavior

When no session exists, the container should:

  • Fall back to username/password authentication
  • Trigger fresh Apple login flow (2FA prompt)
  • Create a new session file after successful login

🔍 Observations / possible root cause

It appears the application always attempts token authentication first:

_authenticate_with_token()

even when:

  • No session file exists
  • No valid token is available

This leads to a failure inside icloudpy:

ICloudPyAPIResponseException('Missing apple_id field')

It looks like an unhandled or invalid token state is being passed into the authentication flow, causing a crash before fallback authentication can occur.


🧪 Environment

  • Image: mandarons/icloud-drive:latest
  • Docker version: Docker version 29.6.0, build fb59821
  • OS: Linux Debian
  • UID/GID: 1000:1000
Image

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions