Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parts Browser: Run queued changes in reverse #2387

Merged
merged 1 commit into from
Jul 13, 2024

Conversation

ThePuzzlemaker
Copy link
Contributor

This prevents an edge case I encountered where the following occurs:

  • The user creates a new part, and forgets to add certain info (in my case, I forgot to check the "RP-1" box), and presses "Queue Changes"
  • The user edits that part, and queues those changes
  • The user presses "Commit Changes to JSON Files"
  • Operation fails, console shows exception:
Traceback (most recent call last):
  File "flask\app.py", line 2190, in wsgi_app
  File "flask\app.py", line 1486, in full_dispatch_request
  File "flask\app.py", line 1484, in full_dispatch_request
  File "flask\app.py", line 1469, in dispatch_request
  File "app.py", line 168, in commit_changes
    part_data.add_new_part(part)
  File "part_data.py", line 25, in add_new_part
    print(f'Adding new part with name: {new_part["name"]}')
                                        ~~~~~~~~^^^^^^^^
KeyError: 'name'

This is because the "edit" queued change is executed before the part is even created, causing issues. Running queued changes in reverse should prevent any issues with this in most cases, assuming the browser/frontend is sane and does not randomly order queued changes.

P.S. looks like GH decided to add a newline. If you want me to update the commit without that extra NL let me know.

This prevents an edge case I encountered where the following occurs:
- The user creates a new part, and forgets to add certain info (in my case, I forgot to check the "RP-1" box), and presses "Queue Changes"
- The user edits that part
- The user presses "Commit to JSON"
- Operation fails, console shows exception:
```
Traceback (most recent call last):
  File "flask\app.py", line 2190, in wsgi_app
  File "flask\app.py", line 1486, in full_dispatch_request
  File "flask\app.py", line 1484, in full_dispatch_request
  File "flask\app.py", line 1469, in dispatch_request
  File "app.py", line 168, in commit_changes
    part_data.add_new_part(part)
  File "part_data.py", line 25, in add_new_part
    print(f'Adding new part with name: {new_part["name"]}')
                                        ~~~~~~~~^^^^^^^^
KeyError: 'name'
```

This is because the "edit" queued change is executed before the part is even created, causing issues. Running queued changes in reverse should prevent any issues with this in most cases, assuming the browser/frontend is sane and does not randomly order queued changes.
@Capkirk123
Copy link
Member

Looks good, but will require the parts browser .exe to be rebuilt

@Capkirk123 Capkirk123 merged commit 7ba2ff0 into KSP-RO:master Jul 13, 2024
3 checks passed
Capkirk123 added a commit that referenced this pull request Jul 13, 2024
@ThePuzzlemaker ThePuzzlemaker deleted the patch-1 branch July 13, 2024 17:53
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