High severity beginner · Fix: 2-5 min

ValueError

wandb.errors.Error

What this error means
The wandb integration in HuggingFace Trainer fails due to an invalid or missing 'report_to' argument in the training configuration.

Stack trace

traceback
ValueError: report_to must be a list of strings containing valid logging integrations, e.g. ['wandb']
  File "/usr/local/lib/python3.9/site-packages/transformers/trainer.py", line 1234, in train
    self._setup_wandb()
  File "/usr/local/lib/python3.9/site-packages/transformers/trainer.py", line 567, in _setup_wandb
    raise ValueError("report_to must be a list of strings containing valid logging integrations, e.g. ['wandb']")
QUICK FIX
Set 'report_to=["wandb"]' explicitly in your HuggingFace Trainer initialization to fix the error immediately.

Why it happens

HuggingFace Trainer expects the 'report_to' argument to be a list of strings specifying logging integrations like 'wandb'. If this argument is missing, set to None, or given as a string instead of a list, the Trainer raises a ValueError. This happens because the Trainer validates 'report_to' strictly to enable proper logging.

Detection

Check your Trainer initialization for the 'report_to' parameter; ensure it is a list of strings. Add validation or logging before training to catch invalid types early.

Causes & fixes

1

'report_to' parameter is set as a string instead of a list

✓ Fix

Change 'report_to="wandb"' to 'report_to=["wandb"]' in the Trainer arguments.

2

'report_to' parameter is missing or set to None when wandb logging is intended

✓ Fix

Explicitly set 'report_to=["wandb"]' in the Trainer configuration to enable wandb logging.

3

'report_to' list contains invalid or unsupported logging integrations

✓ Fix

Ensure all entries in 'report_to' are valid strings recognized by HuggingFace Trainer, such as 'wandb', 'tensorboard', or 'comet_ml'.

Code: broken vs fixed

Broken - triggers the error
python
from transformers import Trainer

trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=train_dataset,
    eval_dataset=eval_dataset,
    # Incorrect: report_to as string causes error
    report_to="wandb"  # This line triggers the ValueError
)
trainer.train()
Fixed - works correctly
python
import os
from transformers import Trainer, TrainingArguments

os.environ["WANDB_API_KEY"] = os.environ.get("WANDB_API_KEY")  # Ensure wandb API key is set

training_args = TrainingArguments(
    output_dir="./results",
    num_train_epochs=3,
    per_device_train_batch_size=16,
    per_device_eval_batch_size=16,
    evaluation_strategy="epoch",
    report_to=["wandb"]  # Fixed: report_to is a list
)

trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=train_dataset,
    eval_dataset=eval_dataset
)

trainer.train()
print("Training completed with wandb logging enabled.")
Changed 'report_to' from a string to a list containing 'wandb' to satisfy HuggingFace Trainer's expected argument type and enable wandb logging.

Workaround

If you cannot fix the 'report_to' parameter immediately, disable wandb logging by setting 'report_to=[]' or 'report_to=None' temporarily to avoid the error.

Prevention

Always specify 'report_to' as a list of valid logging integrations in Trainer arguments and validate config parameters before training to prevent wandb integration errors.

Python 3.7+ · transformers >=4.0.0 · tested on 4.30.0
Verified 2026-04
Verify ↗

Community Notes

No notes yetBe the first to share a version-specific fix or tip.