Troubleshooting¶
Guide to solving common problems.
Connection Errors¶
SourceUnavailableError¶
Cause: Data source not reachable after all attempts.
Solutions:
- Check your internet connection
- Try offline mode:
- Wait and try again (the source may be temporarily down)
- Check whether a configured proxy might be blocking
TimeoutError¶
Cause: The request took too long.
Solutions:
- Increase the timeout:
- Check your connection
- Try during lower-traffic hours
403 Forbidden (CEPEA)¶
Cause: Cloudflare blocking direct requests to CEPEA.
Solution: agrobr automatically uses Notícias Agrícolas as a fallback (pure httpx, no Playwright). If it still fails:
- Try forcing a refresh:
- Use offline mode with cached data:
Parsing Errors¶
ParseError¶
Cause: The source layout changed and the parser cannot extract data.
Solutions:
- Upgrade agrobr:
- Check GitHub issues for known problems
- Use cached data while the problem is fixed:
Empty or Incomplete Data¶
Cause: The source returned partial data.
Checks:
- Is the product correct?
- Does the requested period have data?
- Try a smaller period
Validation Errors¶
ValidationError¶
Cause: Data did not pass Pydantic or statistical validation.
Solutions:
- Make sure you are using a valid product
- Disable statistical validation if needed:
Statistical Anomalies¶
Cause: Values outside the expected historical range.
With validate_sanity=True, anomalies are flagged in the DataFrame's anomalies column (they do not block the return) and logged. There is no specific exception or warning for anomalies.
This is normal when: - Prices had atypical variation (market events) - New-crop data with different volumes
To check: - Compare with other sources - Check sector news
Cache Errors¶
DuckDB Lock / Segfault in Multi-Thread¶
Cause: DuckDB's DuckDBPyConnection is not thread-safe. If agrobr
is used in a multi-thread process (e.g. MCP server, FastAPI with threads),
concurrent calls to the cache can cause a segfault or deadlock.
Solution: As of v0.10.1, DuckDBStore uses an internal
threading.Lock in all methods. If you are on an earlier version,
upgrade:
Corrupted Cache¶
Cause: Problem with DuckDB or a corrupted cache file.
Solution: delete the cache file (recreated on next use):
Cache Not Updating¶
Cause: A fresh cache is being returned.
Solution:
Polars Issues¶
ImportError: polars not found¶
Cause: Polars not installed.
Solution:
Conversion Fails¶
Cause: Incompatible types in the pandas → polars conversion.
Solution: Use pandas (default) and convert manually if needed.
CLI Issues¶
Command not found: agrobr¶
Cause: CLI not installed on PATH.
Solutions:
- Check the installation:
- Reinstall:
- Use via Python:
Encoding on Windows¶
Cause: The terminal does not support UTF-8.
Solution:
# PowerShell
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
# Or export to a file
agrobr cepea indicador soja --formato csv > soja.csv
Debug¶
Enable Detailed Logs¶
# Via CLI
agrobr --verbose cepea indicador soja
# Via code
import logging
logging.basicConfig(level=logging.DEBUG)
View Current Configuration¶
Check Source Health¶
Inspect Cache¶
Reporting Bugs¶
If the problem persists:
- Check whether an issue already exists: https://github.com/bruno-portfolio/agrobr/issues
- Collect information:
- Open an issue with:
- Python and agrobr versions
- Operating system
- Code that triggers the error
- Full error message
- Debug logs (if possible)
FAQ¶
Does agrobr work in Jupyter?¶
Yes! Use the async version directly:
Or the sync version:
Can I use it with proxies?¶
There is currently no native support. Consider configuring a proxy at the system level.
Is the data free?¶
Yes, all sources are public and free. agrobr just makes access easier.
How often is the data updated?¶
| Source | Frequency |
|---|---|
| CEPEA | Daily (~18h) |
| CONAB | Monthly |
| IBGE PAM | Annual |
| IBGE LSPA | Monthly |