# Anonymous users cannot export CSVs

**URL:** <https://speciforum.org/t/anonymous-users-cannot-export-csvs/2318>\
**Category:** Get Help\
**Created:** [February 5, 2025, 4:58pm UTC](https://speciforum.org/t/anonymous-users-cannot-export-csvs/2318 "2025-02-05T16:58:03Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![nfshoobs](https://yyz1.discourse-cdn.com/flex029/user_avatar/speciforum.org/nfshoobs/32/3979_2.png) [@nfshoobs](https://speciforum.org/u/nfshoobs)\
**Post date:** [February 5, 2025, 4:58pm UTC](https://speciforum.org/t/anonymous-users-cannot-export-csvs/2318/1 "2025-02-05T16:58:03Z")

</div>

Specify v7.9.6.1

On the OSU production instance at [invertebrates.osu.edu](https://invertebrates.osu.edu), the anonymous user (testuser) cannot export query results as a .csv.  
This does not seem to be the same issue as [Export to CSV does not notify the user](https://speciforum.org/t/export-to-csv-does-not-notify-the-user/1639), because the .csv is never created. Even when reloading the page multiple times and navigating to other pages, trying the export again, etc.

When signed in as any other user with the same permissions as the anonymous user, query results _can_ be exported.

On the back end, we get this error when anonymous users press the ‘Create CSV’ button:

```auto
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/specify7/specifyweb/stored_queries/execution.py", line 153, in do_export
    field_specs = field_specs_from_json(spquery['fields'])
  File "/opt/specify7/specifyweb/stored_queries/execution.py", line 134, in field_specs_from_json
    for data in sorted(json_fields, key=lambda field: field['position'])]
  File "/opt/specify7/specifyweb/stored_queries/execution.py", line 134, in <lambda>
    for data in sorted(json_fields, key=lambda field: field['position'])]
KeyError: 'position'

```

Steps to reproduce:

- Navigate to Sp7 instance with anonymous user configured
- Run any query
- Click ‘Create CSV’

---

<div class="post-metadata">

**Author:** ![markp](https://yyz1.discourse-cdn.com/flex029/user_avatar/speciforum.org/markp/32/1184_2.png) [@markp](https://speciforum.org/u/markp)\
**Post date:** [February 5, 2025, 5:20pm UTC](https://speciforum.org/t/anonymous-users-cannot-export-csvs/2318/2 "2025-02-05T17:20:54Z")

</div>

Hi @nfshoobs

I am able to export a query for CollectionObjects between the range of `000000001` and `000000005` without error. Is there a particular query (or set of queries) that are failing? It may have something to do with the tables or fields used.

Best,  
Mark

---

<div class="post-metadata">

**Author:** ![nfshoobs](https://yyz1.discourse-cdn.com/flex029/user_avatar/speciforum.org/nfshoobs/32/3979_2.png) [@nfshoobs](https://speciforum.org/u/nfshoobs)\
**Post date:** [February 5, 2025, 7:47pm UTC](https://speciforum.org/t/anonymous-users-cannot-export-csvs/2318/3 "2025-02-05T19:47:15Z")

</div>

@markp I’m having weirdly inconsistent results. I’ve tried it with the stock queries from the taxon tiles, and also using query [https://invertebrates.osu.edu/specify/query/93/](https://invertebrates.osu.edu/specify/query/93/) .  
Over the last two hours, some of the time I’ve been able to export, and other times not.  
We rebuilt our docker container and pulled the updates that were pushed today (having last updated 4 months ago) and that seemed to have fixed the issue at first, but I haven’t been able to get it to generate an export as the anon user on my end for the last hour.

It may be a problem with our server infrastructure and not a specify problem. Our IT is looking into it.

---

<div class="post-metadata">

**Author:** ![markp](https://yyz1.discourse-cdn.com/flex029/user_avatar/speciforum.org/markp/32/1184_2.png) [@markp](https://speciforum.org/u/markp)\
**Post date:** [February 5, 2025, 8:57pm UTC](https://speciforum.org/t/anonymous-users-cannot-export-csvs/2318/4 "2025-02-05T20:57:35Z")

</div>

Hi @nfshoobs,

This is entirely my opinion and unsolicited advice, but I would avoid pulling from a commit and using in production (based on the version information it looks like you are now running `e1e47642f98ffc3e7e54c6cba50f79c3d38f9b2e`) , it may cause you some additional headaches. Instead, you can pull from the latest tagged release, which would be 7.9.6.2. It also helps both others and the Specify team with debugging issues.

The Specify team may outline additional required steps or breaking changes in the release notes for a given release, and directly pulling from a commit skips over that.

If you are using docker, you can use `v7` as the tag, to pull the latest tagged release.

---

<div class="post-metadata">

**Author:** ![nfshoobs](https://yyz1.discourse-cdn.com/flex029/user_avatar/speciforum.org/nfshoobs/32/3979_2.png) [@nfshoobs](https://speciforum.org/u/nfshoobs)\
**Post date:** [February 7, 2025, 8:45pm UTC](https://speciforum.org/t/anonymous-users-cannot-export-csvs/2318/5 "2025-02-07T20:45:47Z")

</div>

Hey @markp, this was something our IT staff suggested when we ran into problems, so I’ll relay the message to them that it’s best to only do the tagged releases.  
RE the issue that spawned this topic, it appears to have been transient. I thought for sure it must have been a permissions issue (due to the fact that only the anonymous user was unable to generate reports) but since it fixed itself without my updating permissions, I’m still in the dark as to why it happens.

---

<div class="post-metadata">

**Author:** ![nfshoobs](https://yyz1.discourse-cdn.com/flex029/user_avatar/speciforum.org/nfshoobs/32/3979_2.png) [@nfshoobs](https://speciforum.org/u/nfshoobs)\
**Post date:** [February 18, 2025, 11:29pm UTC](https://speciforum.org/t/anonymous-users-cannot-export-csvs/2318/6 "2025-02-18T23:29:29Z")

</div>

update: I am pretty certain that this actually has to do with the issue of multiple users concurrently viewing a collection page as an anonymous user. Today I was doing a demo of our DB for other staff in the division and we ran into the error again (with all 3 of us on separate computers looking at the same query). We were only able to generate a .csv when we had all closed all browser tabs on all machines, and reopened, requested the file, and refreshed on ONE machine.

---

<div class="post-metadata">

**Author:** ![nfshoobs](https://yyz1.discourse-cdn.com/flex029/user_avatar/speciforum.org/nfshoobs/32/3979_2.png) [@nfshoobs](https://speciforum.org/u/nfshoobs)\
**Post date:** [July 16, 2025, 6:30pm UTC](https://speciforum.org/t/anonymous-users-cannot-export-csvs/2318/7 "2025-07-16T18:30:32Z")

</div>

Hey Specify team!  
This issue has persisted and is still causing headaches for our users.  
Anonymous users can only sporadically generate a CSV from the back end. Front end CSV export (by clicking checkboxes in the queries) works as expected.  
Any insights?

---

<div class="post-metadata">

**Author:** ![Grant](https://yyz1.discourse-cdn.com/flex029/user_avatar/speciforum.org/grant/32/4255_2.png) [@Grant](https://speciforum.org/u/Grant)\
**Post date:** [July 17, 2025, 5:43pm UTC](https://speciforum.org/t/anonymous-users-cannot-export-csvs/2318/9 "2025-07-17T17:43:43Z")

</div>

Hi @nfshoobs–

@bhumikagupta and I were troubleshooting the issue and she found that some queries on your instance were able to always export to CSV while others never could. After she recognized the pattern, I downloaded the “1 - Search for Specimens / Lots” query and imported it into a local copy of Specify with debug mode on.

I found that I was able to consistently reproduce the behavior you describe (back end queries would not generate) on this query and on “Query: 3 - Create a Species List by Water Body/County/State/Country”, but not on others I downloaded from your instance.

Checking the logs on my machine, I found the following:

```auto
[17/Jul/2025 12:38:09] [DEBUG] [specifyweb.stored_queries.execution:315] query_to_csv starting
Exception in thread Thread-1493:
Traceback (most recent call last):
  File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.9/threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/specify7/specifyweb/stored_queries/execution.py", line 243, in do_export
    query_to_csv(session, collection, user, tableid, field_specs, path,
  File "/opt/specify7/specifyweb/stored_queries/execution.py", line 321, in query_to_csv
    with open(path, 'w', newline='', encoding=encoding) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/volumes/static-files/depository/1 - Search for Specimens / Lots - Thu Jul 17 2025.csv'

```

This translates to Specify not being able to retrieve the CSV file due to the path being invalid, which is caused by the system literally interpreting the `/` (slash) character improperly. After editing the query title to remove the slash, I was able to export to CSV without any issues.

Can you remove the slash from these query names and let me know if you are still seeing this behavior?

---

<div class="post-metadata">

**Author:** ![nfshoobs](https://yyz1.discourse-cdn.com/flex029/user_avatar/speciforum.org/nfshoobs/32/3979_2.png) [@nfshoobs](https://speciforum.org/u/nfshoobs)\
**Post date:** [July 17, 2025, 5:56pm UTC](https://speciforum.org/t/anonymous-users-cannot-export-csvs/2318/10 "2025-07-17T17:56:39Z")

</div>

Brilliant! another case where special characters in the front end cause trouble in the back end.

This fixes the issue as far as I can tell.

Thanks to both of you! 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex029/uploads/specifysoftware/original/2X/1/18a843c97bc32b40e8ad0e035755bc88ffaacaf7.svg) [@system](https://speciforum.org/u/system)\
**Post date:** [July 24, 2025, 5:57pm UTC](https://speciforum.org/t/anonymous-users-cannot-export-csvs/2318/11 "2025-07-24T17:57:27Z")

</div>

Closed on July 24, 2025, 5:57pm UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
