Skip to content

fix(image_generate,resource_copy): add fallback for attachment key mi…#92

Open
DivXPro wants to merge 1 commit into
qqqqqf-q:mainfrom
DivXPro:fix/attachment-key-prefix-fallback
Open

fix(image_generate,resource_copy): add fallback for attachment key mi…#92
DivXPro wants to merge 1 commit into
qqqqqf-q:mainfrom
DivXPro:fix/attachment-key-prefix-fallback

Conversation

@DivXPro

@DivXPro DivXPro commented May 28, 2026

Copy link
Copy Markdown
Contributor

…ssing attachments/ prefix

When the LLM constructs an attachment key without the leading attachments/ prefix (e.g. // instead of attachments///), both image_generate and resource_copy fail because the actual filesystem path includes the prefix.

  • image_generate loadInputImages: after artifact and attachment store lookups fail, retry with attachments/ prefix if missing
  • resource_copy authorizeObjectKey: after Head() returns not-found, retry with attachments/ prefix if key lacks it
  • Also adds messageAttachmentStore field + WithMessageAttachmentStore to ToolExecutor (was missing on current main branch)

…ssing attachments/ prefix

When the LLM constructs an attachment key without the leading
attachments/ prefix (e.g. <accountID>/<msgID>/<file> instead
of attachments/<accountID>/<msgID>/<file>), both image_generate
and resource_copy fail because the actual filesystem path
includes the prefix.

- image_generate loadInputImages: after artifact and attachment
  store lookups fail, retry with attachments/ prefix if missing
- resource_copy authorizeObjectKey: after Head() returns not-found,
  retry with attachments/ prefix if key lacks it
- Also adds messageAttachmentStore field + WithMessageAttachmentStore
  to ToolExecutor (was missing on current main branch)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5203eab8f5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +53 to +56
func (e *ToolExecutor) WithMessageAttachmentStore(s objectstore.Store) *ToolExecutor {
e.messageAttachmentStore = s
return e
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Wire the attachment store into image generation

This setter is never used by the production registration path: registerStoredArtifactTools still constructs imagegeneratetool.NewToolExecutor(...) without chaining WithMessageAttachmentStore(attachmentStore). As a result, in normal worker/desktop composition messageAttachmentStore remains nil, so the fallback added below for unprefixed attachment keys is dead code and input_images that only exist in the message-attachment bucket still fail.

Useful? React with 👍 / 👎.

Comment on lines +126 to +128
if err != nil && objectstore.IsNotFound(err) && attachment && !strings.HasPrefix(key, "attachments/") {
info, err = store.Head(ctx, "attachments/"+key)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Fetch the same fallback key that was authorized

When an attachment is passed as attachment:<account_id>/... and the object exists only at attachments/<account_id>/..., this fallback can authorize the prefixed object, but fetch then calls getObject(ctx, e.AttachmentStore, key) with the original unprefixed key. In real stores where GetWithContentType returns not-found for the unprefixed key, the copy still fails after authorization succeeds; the resolved fallback key needs to be used for the subsequent read as well.

Useful? React with 👍 / 👎.

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.

1 participant