Skip to content

refactor: quick-win cleanup — panic stubs, SaveToFile, dead code, error handling, syncWriter#4

Closed
retran wants to merge 1 commit intomainfrom
pr1-quick-wins
Closed

refactor: quick-win cleanup — panic stubs, SaveToFile, dead code, error handling, syncWriter#4
retran wants to merge 1 commit intomainfrom
pr1-quick-wins

Conversation

@retran
Copy link
Copy Markdown
Owner

@retran retran commented Apr 23, 2026

Why

The executor and SDK layers have accumulated several code hygiene issues during rapid feature development: panicking stubs that crash at runtime instead of delegating to existing implementations, silently discarded errors that hide data corruption and debugging signals, a background catalog build that never propagates results back to the main executor, a SQL injection vector in SaveToFile, and dead code that adds maintenance burden. This PR addresses all of these as a zero-feature-change cleanup, reducing the risk surface before the upcoming nanoflow and WASM work.

What

  • Panic stubs → delegation: 3 SerializeWidget/ClientAction/WorkflowActivity stubs now delegate to existing mpr.Serialize* free functions instead of panicking
  • SaveToFile hardening: Escape single quotes in VACUUM INTO path; remove unused destDB open
  • Dead code removal: Delete types.Hash + mpr.Hash (zero callers, weak positional checksum)
  • Background catalog propagation: Add SyncCatalog callback with sync.RWMutex protection so REFRESH CATALOG BACKGROUND results are visible to subsequent commands; close old catalog on replacement
  • Synchronized output: syncWriter (mutex-wrapped io.Writer) prevents interleaved output between background goroutine and main dispatch loop
  • Error handling: 7 previously-discarded errors now logged or propagated — updateTransactionID returns error, widgetStmt.Exec propagates, 4 sites get log-and-continue warnings
  • refactor: remove ExecContext.executor back-pointer mendixlabs/mxcli#274 review follow-ups: Unexport EnsureSqlMgr, document syncBack cancellation behavior

Verification

  • make build && make test && make lint-go passes
  • 15 files changed, 106 insertions, 75 deletions
  • No behavior changes for correct inputs; new diagnostics for edge cases

Copilot AI review requested due to automatic review settings April 23, 2026 14:16
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Cleanup-focused refactor that hardens error handling, removes dead code, replaces panic stubs with real implementations, and addresses background catalog update propagation/concurrency in the executor/catalog paths.

Changes:

  • Propagate/record previously-discarded errors (including _Transaction update in MPR v2 writes and widget insert failures) and add warning logs where appropriate.
  • Fix background catalog propagation by adding SyncCatalog callback + catalogMu protection, and add a synchronized writer wrapper for background output.
  • Remove unused hashing helpers/tests and harden Catalog.SaveToFile by escaping single quotes for VACUUM INTO.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
sdk/mpr/writer_units.go updateTransactionID() now returns error and is propagated at call sites.
sdk/mpr/utils.go Removes unused Hash wrapper.
mdl/types/id.go Removes unused types.Hash implementation.
mdl/types/id_test.go Removes tests for deleted Hash.
mdl/executor/executor_dispatch.go Adds catalogMu usage and SyncCatalog callback wiring; documents cancellation behavior.
mdl/executor/executor.go Adds catalogMu field to protect background catalog updates.
mdl/executor/exec_context.go Adds SyncCatalog hook; unexports ensureSqlMgr.
mdl/executor/cmd_sql.go Updates to call ctx.ensureSqlMgr().
mdl/executor/cmd_pages_builder_v3.go Logs warnings instead of discarding lookup errors.
mdl/executor/cmd_page_wireframe.go Logs warning if describePage fails instead of silently discarding error.
mdl/executor/cmd_microflows_builder_calls.go Logs warning if Java action lookup fails instead of discarding error.
mdl/executor/cmd_catalog.go Adds syncWriter, background catalog propagation via SyncCatalog, and warns on writeResult failure.
mdl/catalog/catalog.go Removes unused destination DB open; escapes quotes in path for VACUUM INTO.
mdl/catalog/builder_pages.go Propagates widget insert errors instead of discarding; wraps with context.
mdl/backend/mpr/backend.go Replaces panicking serialization stubs with delegation to existing mpr.Serialize* functions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mdl/executor/executor_dispatch.go
Comment thread mdl/executor/cmd_catalog.go
Comment thread sdk/mpr/writer_units.go
Comment thread sdk/mpr/writer_units.go
Comment thread mdl/executor/executor.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mdl/executor/executor_dispatch.go Outdated
Comment thread mdl/executor/cmd_catalog.go
Comment thread mdl/executor/cmd_pages_builder_v3.go
Comment thread mdl/executor/cmd_page_wireframe.go
Comment thread mdl/executor/cmd_microflows_builder_calls.go
Comment thread sdk/mpr/writer_units.go Outdated
Comment thread mdl/executor/executor_dispatch.go Outdated
@retran retran requested a review from Copilot April 23, 2026 14:40
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@retran retran requested a review from Copilot April 23, 2026 14:42
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mdl/executor/executor_dispatch.go
Comment thread sdk/mpr/utils.go
Comment thread mdl/types/id.go
Comment thread mdl/executor/cmd_catalog.go
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mdl/executor/cmd_catalog.go Outdated
Comment thread mdl/executor/executor.go
Comment thread sdk/mpr/writer_units.go
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mdl/executor/executor_dispatch.go
Comment thread mdl/executor/executor_dispatch.go
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 90 out of 103 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mdl/executor/cmd_rest_clients.go
@retran retran requested a review from Copilot April 23, 2026 19:50
@retran retran changed the base branch from feature/catalogdb-interface to main April 23, 2026 19:54
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 20 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 20 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mdl/executor/cmd_catalog.go
@retran
Copy link
Copy Markdown
Owner Author

retran commented Apr 23, 2026

Superseded by upstream PR mendixlabs#287

@retran retran closed this Apr 23, 2026
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