Skip to content

Fix search --csv file name when the name ends with .csv - #120

Merged
const-cloudinary merged 2 commits into
masterfrom
fix/search-csv-file-name
Sep 27, 2026
Merged

const-cloudinary merged 2 commits into
masterfrom
fix/search-csv-file-name

Conversation

@TalLevAmi

Copy link
Copy Markdown
Contributor

cld search <query> --csv out.csv wrote the file out.csv.csv. A script that reads out.csv after the command fails. The log line showed the doubled name, but the help text says --csv <filename>.

Brief Summary of Changes

  • write_json_list_to_csv (cloudinary_cli/utils/utils.py) adds .csv only when the name does not end with .csv (case-insensitive). It returns the file name that it wrote.
  • search and search_folders log that file name.
  • A name with no extension, for example --csv out, still gives out.csv, as before.

What does this PR address?

  • GitHub issue (Add reference - #XX)
  • Refactoring
  • New feature
  • Bug fix
  • Adds more tests

Are tests included?

  • Yes
  • No

Reviewer, please note:

  • No change for users who pass a name with no extension.

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I ran the full test suite before pushing the changes and all the tests pass.

Local test run: I ran the full suite on Python 3.8 with Click 8.1.8. The new tests pass, and they fail without the fix. 8 tests in test_cli_agent.py and test_cli_config_oauth.py fail with stderr not separately captured on this branch and on master too. These tests need Click 8.2, which needs Python 3.10 or later. CI must confirm the full result.

🤖 Generated with Claude Code

TalLevAmi and others added 2 commits September 26, 2026 15:49
`cld search ... --csv out.csv` wrote `out.csv.csv`, because the writer
always added `.csv` to the name.

- `write_json_list_to_csv` adds `.csv` only when the name does not
  already end with it (case-insensitive), and returns the file name.
- `search` logs the real file name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On macOS and Windows, `out.CSV` and `out.csv` are the same file, so
the directory listing had one file, not two. Remove the listing check.
The check of the returned file name still finds the `out.csv.csv` bug.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@TalLevAmi
TalLevAmi marked this pull request as ready for review September 26, 2026 16:15
@const-cloudinary
const-cloudinary merged commit e42eefa into master Sep 27, 2026
8 checks passed
@const-cloudinary
const-cloudinary deleted the fix/search-csv-file-name branch September 27, 2026 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants