Skip to content

Fix: Workflow#save passes I18n key as string literal instead of calling I18n.t#5489

Open
ddri wants to merge 1 commit into
OSC:masterfrom
ddri:fix/workflow-i18n-error-message
Open

Fix: Workflow#save passes I18n key as string literal instead of calling I18n.t#5489
ddri wants to merge 1 commit into
OSC:masterfrom
ddri:fix/workflow-i18n-error-message

Conversation

@ddri
Copy link
Copy Markdown
Contributor

@ddri ddri commented May 27, 2026

The Workflow#save guards against a nil project_dir by adding an error and returning early.
The error message was passed as a string literal containing the I18n method call rather
than invoking it:

# Before
errors.add(:save, "I18n.t('dashboard.jobs_project_directory_error')")

# After
errors.add(:save, I18n.t('dashboard.jobs_project_directory_error'))

The WorkflowsController always provides project_dir via permit_params, so this guard
only fires outside the normal controller flow, for direct model instantiation, rails console,
or API usage without a project context. In those cases the error bubbles up through
handle_workflow_errorcollect_errors, producing the flash message:

"There was an error processing your request: I18n.t('dashboard.jobs_project_directory_error')"

instead of the translated string "Project directory path is not set for this workflow".

Changes

  • app/models/workflow.rb — call I18n.t instead of quoting it as a string
  • test/models/workflow_test.rb
    • Add test asserting that save without project_dir returns the translated error message
    • Fix two pre-existing assertions that were silently passing regardless of error state: assert workflow.errors.inspectassert_empty workflow.errors

Copy link
Copy Markdown
Contributor

@johrstrom johrstrom left a comment

Choose a reason for hiding this comment

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

This appears to have commits/changes from a different branch in them.

@github-project-automation github-project-automation Bot moved this from Awaiting Review to Changes Requested in PR Review Pipeline May 27, 2026
…ranslated message

errors.add(:save, "I18n.t(...)") passes the method call as a string
literal. Calling I18n.t directly returns the translated string.

Also fix two pre-existing assertions that were silently passing regardless
of error state: assert workflow.errors.inspect → assert_empty workflow.errors
@ddri ddri force-pushed the fix/workflow-i18n-error-message branch from 54ab4dc to 54598a2 Compare May 28, 2026 05:15
@ddri
Copy link
Copy Markdown
Contributor Author

ddri commented May 28, 2026

Thanks for catching that — the app_helper changes belonged in a separate PR and got mixed in by mistake. Rebased onto current master, diff now only contains the workflow.rb and workflow_test.rb changes.

Copy link
Copy Markdown
Contributor

@Bubballoo3 Bubballoo3 left a comment

Choose a reason for hiding this comment

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

This looks good to me!

@Bubballoo3 Bubballoo3 requested a review from johrstrom May 29, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Changes Requested

Development

Successfully merging this pull request may close these issues.

4 participants