Corrupted project json files after faulty reattaching

Hi,

I had a project on cryosparc instance 1. I detached the project from there and tried to attach it to another instance (instance 2). During reattaching in instance 2, the database filesystem got full and the reattachment did not complete and cryoSPARC was showing error in connecting. I proceeeded with cleaning up the filesystem to make space and tried to start cryoSPARC again. It started normally.

But when I opened by newly attached project, some of the last jobs in the last workspace were missing. Only half the jobs were showing up. I waited for sometime for it to load, but still didn’t help. I tried to detach and reattach the project. I am guessing that was probably a bad idea, as the project.json, job_manifest.json and workspace.json files got overwritten and do not show the missing jobs either now. However, those job directories and data do exist in the project directory. They are just not reflected in the json file and hence cryoSPARC can’t see it.

I was wondering if there is any way to recreate these json files with all the information about these missing jobs.

Thank you
Adwaith

Continuously monitor the database storage for available storage to avoid a similar problem from arising in the future.

There may be, but the following procedure has not been tested.

  1. Detach the project directory.
  2. Prepare and set aside a copy of the project directory, in case the following steps result in unintended and unwanted changes to the project directory.
  3. Post under this topic any questions you may have regarding the procedure below.
  4. Save the following script to a file build_manifest.py:
    project_dir = "/path/to/unattached/copy/of/projectdir/"
    manifest_path = "/tmp/WpPwiAf5vi.job_manifest.json"
    failed_job_docs_path = "/tmp/WpPwiAf5vi.failed.json"
    
    import pathlib
    import json
    
    jobs = []
    failed_job_dirs = {}
    
    for doc in pathlib.Path(project_dir).glob('J*/job.json'):
        job_dir = doc.parts[-2]
        with open(doc) as handle:
            try:
                assert job_dir[1:].isdigit(), f"{doc} is not a valid job document path."
                data = json.load(handle)
                assert job_dir == data['uid'], f"Job uid does not match directory name {job_dir}."
                jobs.append(data['uid'])
            except Exception as e:
                failed_job_dirs[job_dir] = str(e)
    
    with open(manifest_path, 'w') as mhandle:
        json.dump({'jobs': sorted(jobs)}, mhandle, indent=4) 
    
    if failed_job_dirs:
        with open(failed_job_docs_path, 'w') as fhandle:
            json.dump(failed_job_dirs, fhandle, indent=4)
    
  5. In build_manifest.py, edit the project_dir definition on the first line to point to the unattached copy of the project directory.
  6. Run the command
    python3 build_manifest.py
  7. The command may take some time to complete. After completion, inspect (without modifying) the *.job_manifest.json and *.failed.json files created by the script inside the /tmp/ directory. *.job_manifest.json should include most job IDs in the project. *.failed.json should include records for a few job IDs along with errors that lead to those job’s exclusion from the job manifest.
  8. Copy the *.job_manifest.json to the unattached project directory as a file named job_manifest.json.
  9. Create a “synthetic” workspaces.json file as described in Attach a project without workspace.json - #2 by wtempel, as applicable given the workspace_uids present in all the project’s jobs’ job.json files.
  10. After creating and placing inside the project directory the job_manifest.json and workspaces.json files, try again attaching the project.

Hi,

Thank you for the detailed solution. I tried the steps as suggested. I was able to create job_manifest.json that included all the jobs in the directory. None of them shows any error. I also created a workspaces.json. I did not modify te project.json at all. But when i try to attach it, no workspaces or jobs show up on the project. However, all the directories still exist in the folder.

Best,
Adwaith

@Adwaith99 Please can you email us the

  1. workspaces.json file
  2. job_manifest.json file
  3. the tgz file created by the command
    cryosparcm snaplogs
  4. the project UID that was assigned during the project attachment attempt

@Adwaith99 Thanks for sending the information. The command_core log, which you may browse using the command

cryosparcm log command_core | less

indicated a problem with the supplied workspaces.json file:

2025-09-03 10:34:30,833 import_project_run   ERROR    |     workspaces_doc_data = load_workspaces_document(abs_path_export_project_dir)
[..]
2025-09-03 10:34:30,833 import_project_run   ERROR    | json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 13 column 5 (char 299)

The actual error is the trailing comma in the preceding line 12 of workspaces.json:

     12         "deleted": false,
     13     },

Removing the comma on line 12 (and, similarly, commas on lines 24, 36, 48, 60, 72) should make workspaces.json readable for the JSON decoder.
After a failed attachment attempt, job_manifest.json may be truncated. If truncation occurred (please check), the file may have to be replaced again by a “synthetic” job_manifest.json (see Corrupted project json files after faulty reattaching - #2 by wtempel) after detachment (if needed) and before a renewed import attempt.

Hi @wtempel,

Thanks for the catch! It seems to be importing all jobs properly, and its behaving properly now. Thanks again for the quick response and fix.

Best,
Adwaith

Hi @wtempel

I encountered a similar situation to this thread and followed the recovery procedure, but it did not succeed. I would greatly appreciate any further advice.

Background:

  • Original project was created and processed in CryoSPARC v4.6.0.
  • I attached it to a new instance running CryoSPARC v5.0.6.
  • After the first attach, only 371 jobs appeared in the UI (out of ~1810 total job directories on disk). Most workspaces were empty.
  • I waited several days with no further jobs appearing, then detached and re-attached the project – still no improvement.
  • At some point I created a new job and received the error “job dir is not empty”.
  • Now both project.json and workspaces.json are incorrect/corrupted.
  • There is no usable backup of the original intact project directory or of the original instance database.

What I have tried (following the procedure in this thread):

  1. Detached the project.
  2. Ran the build_manifest.py script – it successfully produced a job_manifest.json that lists all 1810 jobs.
  3. Created a synthetic workspaces.json based on the workspace UIDs found in the job.json files (25 workspaces expected).
  4. Placed both job_manifest.json and the synthetic workspaces.json into the project directory and tried to attach again.
  5. After attach, no workspaces appear in the UI at all.
  6. I ran cryosparcm snaplogs but did not find obviously useful error messages related to the attachment. I can provide the full log archive or specific excerpts if helpful.

Questions:

  1. Is the recovery procedure from this thread still expected to work on CryoSPARC v5.0.6?
  2. Is there any hope of recovering all ~1810 jobs and the 25 workspaces given that the project has already been incorrectly detached/attached multiple times and there is no remaining backup?
  3. What additional information or files would be most useful for further diagnosis (e.g., contents of the synthetic workspaces.json, job_manifest.json, etc.)?

Thank you very much for any guidance. I understand this is a non-standard recovery situation and may not be fully recoverable.

Best,

Tosyl

Did you detach the project from the v4.6.0 instance?

Was this the first attempt to attach the project, or was there a previous attempt to attach the project to CryoSPARC instance with a version below v5.0.6?

Hi @wtempel,

Thank you for the follow-up questions. The original operator is no longer fully certain about the exact sequence of events.

  1. Did you detach the project from the v4.6.0 instance?
    The project may have been detached (and possibly re-attached) multiple times, on different computers, by different people. There is no clear record of a clean, single detachment from the original v4.6.0 instance.

  2. Was this the first attempt to attach the project, or was there a previous attempt on a version below v5.0.6?
    Earlier attach attempts cannot be ruled out. We do not have reliable logs to confirm this.

In short, the project’s transfer history appears messy :crying_cat:. Would importing the jobs individually be a possible workaround?

Please let us know if this incomplete history changes the recovery outlook, or if any further diagnostic steps would still be useful.

Thank you again for your time and help.

Best,
tosyl

I may iteratively request additional information that may help determine the best aproach.
Let’s start with

  1. Do any jobs show up when you try display all jobs in the imported project, using a URL that ends with
    /browse/P99-W*-J* (when you replace P99 with the project UID of the newly imported project)?
  2. Did the script produce a *.failed.json file? If so, did the file contain any job IDs?

Hi @wtempel,

Do any jobs show up when you try to display all jobs in the imported project?

Yes, I can see almost all the jobs. The footer shows “1749 jobs, 27 Job Types, 3 Statuses”.

Did the script produce a .failed.json file?

No, no *.failed.json was produced.

Please let me know if you need any additional information.

Best,
tosyl

What happens if you try create a workspace in that project?

Hi @wtempel,

Thank you for the continued help.

I created a new workspace in the project. It appears as W26 and contains no jobs.
No old workspaces are visible.

Best,
tosyl

Thanks @tosyl for trying that.
Please can you run these commands and email us the file created with these commands.

csprojectid=P999 # replace P999 with actual project ID
cd $(mktemp -d)
cryosparcm cli "api.projects.find_one('$csprojectid')" > ${csprojectid}_info.txt
cryosparcm cli "api.workspaces.find(project_uid='$csprojectid')" >> ${csprojectid}_info.txt
gzip *txt
realpath *.gz # display path of file to send us

I will send you a personal message with our email address.

Thank you. I have emailed the file to the address you provided.

Thanks @tosyl. We are reviewing the information.