Skip to content

fix: Sentry errors in logs, skills, assets, credentials, and workflow lists - #371

Merged
artempartos merged 7 commits into
developfrom
fix/sentry-errors
Sep 30, 2026
Merged

artempartos merged 7 commits into
developfrom
fix/sentry-errors

Conversation

@Evgeniy-DB

Copy link
Copy Markdown
Collaborator

Summary

This branch fixes several independent crashes and N+1s reported from production. List figures and project access stay the same as in the UI: the same run numbers and the same set of projects.

1. Creating a task asset crashed instead of returning 422

https://aixle-flow.sentry.io/issues/7758859950/?project=4511042944040960&query=is%3Aunresolved&referrer=issue-stream

Problem. POST .../assets always serialized the result through TaskAssetResource, even when the record was not saved. Two ways in:

  • the client sent file as a string ("undefined") rather than an uploaded file — Shrine cannot accept that, and the request crashed;
  • validation failed (blank name) — the controller still tried to render a resource for the unsaved record and answered 500 instead of the model errors.

Change. A string in place of a file returns 422 with "file must be an uploaded file" immediately, and no row is created. If save fails, the response is 422 with the model's errors. A successful upload is still 201 and the asset JSON.

2. The auth-error detector crashed on a binary terminal log

https://aixle-flow.sentry.io/issues/7741565895

Problem. Shrine reads a stored log as ASCII-8BIT. AuthErrorDetector patterns include the character · (Login expired · Please run /login), which is a UTF-8 regexp. As soon as the log holds a byte >= 128, String#match? raises Encoding::CompatibilityError before any verdict. An invalid UTF-8 sequence from a PTY raises ArgumentError. CompleteStepActivity calls the detector after strip_ansi, so Temporal retried the activity and the step received neither auth_expired nor a normal failure.

Change. Bytes are forced to UTF-8 and passed through scrub before matching, in AuthErrorDetector.normalize and in strip_ansi. A login banner in a binary log still marks the step auth_expired. A log with no banner finishes the step as a normal session error and does not raise.

3. list_projects in the personal MCP checked access per row

https://aixle-flow.sentry.io/issues/7746474982

Problem. PersonalTools::Base#accessible_projects loaded every project in the company and called Project#accessible_by? on each row. For an employee who is neither the owner nor a company admin, that is a membership lookup and a project_collaborators exists? per project. Sentry reported the N+1 on MCPController#handle.

Change. The list is one query through Project.for_user — the same reachability as the UI. A pinned project still narrows the scope. A company admin sees every project in the company; an employee sees their own and the ones they were added to as a collaborator.

4. A NUL in SKILL.md crashed the catalog write

https://aixle-flow.sentry.io/issues/7758631241

Problem. A null byte is valid UTF-8, so scrub leaves it in place. Someone else's SKILL.md with \0 in name or description reached the catalog UPDATE, and pg raised inside exec_params with string contains null byte before the query was sent. Demand sync died there.

Change. Skills::SkillMarkdown#normalize deletes \0 before frontmatter is parsed. Name and description are stored without the null byte (pdf\0-processing → pdf-processing).

5. An errored credential refreshed on every model load

https://aixle-flow.sentry.io/issues/7755259119

Problem. An empty model list is not cached. Once the refresh sweep had already marked a credential as error, fetch_or_cache_agent_models still called the vendor on every page that loads agent models: 401, another refresh, and RefreshFailed. The status never cleared itself.

Change. When cred.error? is true, the method returns [] immediately and does not call the API. refresh_failure_count stays unchanged. The vendor is asked again only after re-auth, when the status is active again.

6. Workflow lists loaded every historical run

https://aixle-flow.sentry.io/issues/7721523869

Problem. WorkflowResource computed runs_count, last_run_at, last_run_status, and has_active_runs via runs.size, runs.max_by, and runs.any?. On a list that is a COUNT plus a SELECT * per workflow, and it loads the full run history into memory. The workflows index and the deferred list in Aixle Builder both did this (includes(:runs)). The Run Workflow drawer on the sessions page serialized the same resource even though it only needs id, name, and steps — and paid the same workflow_runs query per workflow.

Change. Workflow.attach_run_stats reads the count, the latest run's time and state, and the active flag (running / paused) in one GROUP BY. The index and the builder attach those stats before WorkflowResource. A single record without a prior attach loads its own row lazily and then reads it from memory. The drawer returns only id, name, and steps, and does not count runs.

Test plan

  • AssetsControllerTest — a file is stored; a string in place of a file and a blank name return 422 and create no row
  • AuthErrorDetectorTest and CompleteStepActivityTest — a banner in a binary log yields auth_expired; a log with no banner does not raise
  • PersonalMCPTest — list_projects issues no per-row membership or collaborator query; an admin sees every project in the company
  • SkillMarkdownTest and CatalogSyncTest — NUL is stripped from name and description before the catalog write
  • CompanyMembershipTest — an errored credential does not call the Cursor API and does not increment refresh_failure_count
  • WorkflowTest / WorkflowResourceTest — run stats come from one query; a created_at tie goes to the higher id
  • workflows index — one query against workflow_runs; the sessions drawer — no per-workflow workflow_runs query

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Refactor / chore
  • Breaking change

How was this tested?

Checklist

  • I read CONTRIBUTING.md.
  • All my commits are signed off for the DCO (git commit -s).
  • I have signed (or will sign) the CLA when the bot prompts me — or my
    organization has executed the Corporate CLA.
  • make check_all passes locally (tests, rubocop, brakeman, eslint, typescript).
  • I added/updated tests where it makes sense.
  • I updated documentation where it makes sense.
  • My commits use clear, descriptive messages.

Evgeniy-DB and others added 7 commits September 30, 2026 23:56
…andling

- Added validation to ensure the uploaded file is an actual file and not a string.
- Improved error handling to return specific messages when asset creation fails due to validation errors.
- Updated tests to cover scenarios for successful file uploads, rejection of invalid file types, and handling of validation failures.

Signed-off-by: Evgeniy Yagnenkov <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
- Introduced a `normalize` method in `AuthErrorDetector` to handle terminal bytes and ensure compatibility with ASCII-8BIT logs, preventing encoding errors during pattern matching.
- Updated the `detect` and `extract_message` methods to utilize the new normalization process.
- Enhanced tests to verify correct behavior when processing binary logs, including scenarios with and without auth banners.

Signed-off-by: Evgeniy Yagnenkov <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
- Added a test to ensure that listing projects does not re-check access for each project, reducing unnecessary database queries and improving performance.
- Introduced a test to verify that all projects in a company administered by the caller are included in the project list.
- Updated the `accessible_projects` method to utilize a single query for project access, enhancing efficiency.

Signed-off-by: Evgeniy Yagnenkov <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
- Updated the `normalize` method to remove null bytes from content, ensuring valid UTF-8 encoding before processing.
- Added tests to verify that null bytes are stripped from skill names and descriptions, preventing errors during database operations.
- Enhanced existing tests to confirm that frontmatter parsing correctly handles content with null bytes.

Signed-off-by: Evgeniy Yagnenkov <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
…ent model fetching

- Updated the `agent_models_for_props` method to return an empty array if the credential is marked as errored, preventing unnecessary refresh attempts and associated errors.
- Added a test to verify that the method does not attempt to refresh a credential already marked as an error, ensuring stability in the agent model loading process.

Signed-off-by: Evgeniy Yagnenkov <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
- Introduced a new method `attach_run_stats` in the `Workflow` model to efficiently gather run statistics (count, last run time, last state, and active status) in a single query, reducing database load.
- Updated `WorkflowResource` to utilize the new run statistics instead of loading runs directly, improving performance and reducing unnecessary data loading.
- Modified various controllers to leverage the new statistics, ensuring that workflows are rendered with accurate run data without excessive queries.
- Enhanced tests to verify the correctness of the new run statistics functionality and ensure that workflows are displayed correctly without counting runs per workflow in certain contexts.

Signed-off-by: Evgeniy Yagnenkov <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
The rebase onto #361 put Project.for_user where Project.where(company_id:
membership_company_ids) used to be. for_user spans every active membership,
while membership_company_ids is the token's proven set, so the bare scope
would list the projects of a company whose sign-in policy the token does
not satisfy. The resolution keeps both; this pins it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
@artempartos
artempartos merged commit 6cfdff9 into develop Sep 30, 2026
7 checks passed
artempartos added a commit that referenced this pull request Oct 2, 2026
…log rows (#401)

* fix(skills): strip null bytes YAML escapes decode into frontmatter

#371 deletes raw NUL from a SKILL.md before parsing, but YAML puts it
back: the double-quoted escapes "\0", "\x00" and "\u0000" decode to NUL,
and `!!binary` decodes to arbitrary bytes that need not be UTF-8. The
catalog backfill then wrote that description and pg refused it with
"string contains null byte".

Scrubbing the parsed tree in one place covers every consumer: the
catalog's name/description, the registry install path, and parse()'s
description and frontmatter title that manual skills and templates store.

Fixes PALAD-AI-TEMPORAL-1M

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>

* fix(skills): rotate a catalog row the backfill cannot write

A row whose write raised was never stamped, so it stayed first in
`undescribed_first` and every later run died on it before anything
behind it got a turn. One upstream SKILL.md stopped the description
backfill and the audit pass for four days.

The row is now reported through Rails.error (forwarded to Sentry, one
issue per error class), counted as failed and stamped, so the queue moves
on. If stamping fails too the database itself is the problem and the run
still fails.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>

---------

Signed-off-by: Artem Petrov <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Evgeniy-DB pushed a commit that referenced this pull request Oct 12, 2026
Add LLM call materialization, query service, and resource layer.
Surface calls as inline collapsible panels on workflow run (tab) and
session (panel) show pages with client-side Model/Session filters.

Remove the standalone workflow run LLM calls page and route.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: Alex Astafyev <[email protected]>
Signed-off-by: Evgeniy Yagnenkov <[email protected]>
Evgeniy-DB pushed a commit that referenced this pull request Oct 14, 2026
Add LLM call materialization, query service, and resource layer.
Surface calls as inline collapsible panels on workflow run (tab) and
session (panel) show pages with client-side Model/Session filters.

Remove the standalone workflow run LLM calls page and route.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: Alex Astafyev <[email protected]>
Signed-off-by: Evgeniy Yagnenkov <[email protected]>
artempartos pushed a commit that referenced this pull request Nov 11, 2026
Add LLM call materialization, query service, and resource layer.
Surface calls as inline collapsible panels on workflow run (tab) and
session (panel) show pages with client-side Model/Session filters.

Remove the standalone workflow run LLM calls page and route.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: Alex Astafyev <[email protected]>
Signed-off-by: Evgeniy Yagnenkov <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
artempartos pushed a commit that referenced this pull request Dec 2, 2026
Refs #371

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Aixle Flow <[email protected]>
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