ernie-research/MEnvBench huggingface dataset:
Repository: vercel/ai (TypeScript)

Issue:
OpenAI provider: Preserve file_id when converting file citations to sources
### Description

The OpenAI responses API returns file citations with **file_id**. This information is lost when converting file citations to sources in the content array. For example https://github.com/vercel/ai/blob/27e8c3aad8e3cdd73f5d8f454cbca92b34580ac2/packages/openai/src/responses/openai-responses-language-model.ts#L478-L486

For our use case, we've implemented our chatbot as an api that adheres to the openai responses API spec, and we've implemented file citations in a way where file_id contains necessary information about the file. It would be nice to preserve the file_id in the source.

### AI SDK Version

"ai": "5.0.17",
"@ai-sdk/openai": "2.0.32",

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct


Discussion: This would require a spec change: 

https://github.com/vercel/ai/blob/0adc679a2c9c1a8b2d2af2d976666e1262dbcc59/packages/provider/src/language-model/v3/language-model-v3-source.ts#L58-L61

We'll consider it for the v6 release, as a spec change is a breaking change. Thanks!
We can store it in the provider metadata. I'll look into a fix.



Fix (patch):
diff --git a/.changeset/orange-ears-itch.md b/.changeset/orange-ears-itch.md
new file mode 100644
index 000000000000..7496895a4cbf
--- /dev/null
+++ b/.changeset/orange-ears-itch.md
@@ -0,0 +1,5 @@
+---
+'@ai-sdk/openai': patch
+---
+
+feat(openai): preserve file_id when converting file citations
diff --git a/packages/openai/src/responses/openai-responses-language-model.ts b/packages/openai/src/responses/openai-responses-language-model.ts
index 8e3b61938a77..27ad41954db4 100644
--- a/packages/openai/src/responses/openai-responses-language-model.ts
+++ b/packages/openai/src/responses/openai-responses-language-model.ts
@@ -481,6 +481,15 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
                   mediaType: 'text/plain',
                   title: annotation.quote ?? annotation.filename ?? 'Document',
                   filename: annotation.filename ?? annotation.file_id,
+                  ...(annotation.file_id
+                    ? {
+                        providerMetadata: {
+                          openai: {
+                            fileId: annotation.file_id,
+                          },
+                        },
+                      }
+                    : {}),
                 });
               }
             }
@@ -1194,6 +1203,15 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV3 {
                     'Document',
                   filename:
                     value.annotation.filename ?? value.annotation.file_id,
+                  ...(value.annotation.file_id
+                    ? {
+                        providerMetadata: {
+                          openai: {
+                            fileId: value.annotation.file_id,
+                          },
+                        },
+                      }
+                    : {}),
                 });
               }
             } else if (isErrorChunk(value)) {
Repository: getsentry/sentry-javascript (TypeScript)

Issue:
[v9] Node ANR sessions missing `attrs.release`
### Description

Suspect this was caused by:
- https://github.com/getsentry/sentry-javascript/pull/14658

We continually pass the session to the ANR worker where it is expected to already have `attrs.release`. The session can then sent from the ANR worker later.

This was picked up by the Electron e2e tests. 

Unfortunately the tests I wrote in this repo for ANR didn't check the release so I only have myself to blame 🫣
https://github.com/getsentry/sentry-javascript/blob/6ba90518942fd729c9578e7a91a3ffade8b5ef34/dev-packages/node-integration-tests/suites/anr/test.ts#L187-L192





Fix (patch):
diff --git a/packages/node/src/integrations/anr/worker.ts b/packages/node/src/integrations/anr/worker.ts
index 8900b423710b..2eebfe40309b 100644
--- a/packages/node/src/integrations/anr/worker.ts
+++ b/packages/node/src/integrations/anr/worker.ts
@@ -46,7 +46,13 @@ async function sendAbnormalSession(): Promise<void> {
   // of we have an existing session passed from the main thread, send it as abnormal
   if (session) {
     log('Sending abnormal session');
-    updateSession(session, { status: 'abnormal', abnormal_mechanism: 'anr_foreground' });
+
+    updateSession(session, {
+      status: 'abnormal',
+      abnormal_mechanism: 'anr_foreground',
+      release: options.release,
+      environment: options.environment,
+    });
 
     const envelope = createSessionEnvelope(session, options.dsn, options.sdkMetadata, options.tunnel);
     // Log the envelope so to aid in testing
Repository: h3js/h3 (TypeScript)

Issue:
Add `onResponse` callback to `sendProxy` and `proxyRequest` 
### Describe the feature

Sometimes it is necessary to add/modify headers for proxy response. For example, we need to add some header or remove `secure` attribute from the cookie.
I suggest to add `onResponse` callback to `sendProxy` and `proxyRequest` (similar to `onProxyRes` in the `http-proxy`), which takes proxy `event` as argument, so we can do:
```ts
return proxyRequest(event, target, {
  headers,
  onResponse(_event) {
    setHeader(_event, 'foo', 'bar')
  }
})
```

### Additional information

- [X] Would you be willing to help implement this feature?


Discussion: I think its better to upgrade `proxyRequest` to make it return modified response instead of sending response directly from method. @pi0 
@oleghalin I guess by "response" you mean - to return the modified `event` (with filtered headers, modified cookies etc.)? But event is already modified after we call `sendProxy`, because it is mutated under the hood. 
We can return the `response`, but then the user should do the additional work to send the proxied response:
 ```ts
const response = await proxyRequest(event, target, {
  headers
})

setHeader(event, 'foo', 'bar')

return toSendStream ? sendStream(event, response.body) : send(event, new Uint8Array(await response.arrayBuffer()))
```
or we can do `event.node.res.write(chunk)` inside `sendProxy` (as it is now), and "delegate" `send` to the user:
```ts
const _event = await proxyRequest(event, target, {
  headers
})

setHeader(_event, 'foo', 'bar')

return send(_event)
```
but in this case returning the `_event` doesn't make sense, because it is already modified, so it can be confusing.
@pi0 Can you please share your thoughts on this? 



Fix (patch):
diff --git a/src/utils/proxy.ts b/src/utils/proxy.ts
index 6e3928506..a69438135 100644
--- a/src/utils/proxy.ts
+++ b/src/utils/proxy.ts
@@ -12,6 +12,7 @@ export interface ProxyOptions {
   sendStream?: boolean;
   cookieDomainRewrite?: string | Record<string, string>;
   cookiePathRewrite?: string | Record<string, string>;
+  onResponse?: (event: H3Event, response: Response) => void;
 }
 
 const PayloadMethods = new Set(["PATCH", "POST", "PUT", "DELETE"]);
@@ -105,6 +106,10 @@ export async function sendProxy(
     event.node.res.setHeader(key, value);
   }
 
+  if (opts.onResponse) {
+    await opts.onResponse(event, response);
+  }
+
   // Directly send consumed _data
   if ((response as any)._data !== undefined) {
     return (response as any)._data;
Repository: payloadcms/payload (TypeScript)

Issue:
User with insufficient access can reassign their own roles on the front-end
### Link to reproduction

https://github.com/hdodov/payload-site/tree/bug-role-access

### Describe the Bug

A user without admin rights can *seemingly* change their own role to an admin. The front-end indicates that everything goes through successfully, but upon refreshing - the actual role is unchanged. It looks like it's entirely a front-end issue. Although the API response indicates success too. Here's a demo:

https://github.com/payloadcms/payload/assets/5570098/a01cba37-6d38-497f-8c70-628a3a8aebaf


### To Reproduce

1. Clone [the repo](https://github.com/hdodov/payload-site/tree/bug-role-access)
2. `npm i`
3. `npm run dev`
4. Open http://localhost:3000/admin
5. Login as `user@payloadcms.com` with password `test2`
6. Open the user settings screen
7. Change the role from `user` to `admin`
8. Click save
9. You'll see the "Updated successfully" toast message
10. Refresh the page
11. You'll see that the role wasn't actually changed

**Expected behavior:** The user should not be able to view the roles field at all because only an admin can:

https://github.com/hdodov/payload-site/blob/bc00cf4b42cffb1fe2483f4adcfac65b00e72b8c/src/collections/Users.ts#L26-L38

### Payload Version

2.0.14

### Adapters and Plugins

db-mongodb



Fix (patch):
diff --git a/packages/payload/src/admin/components/forms/RenderFields/filterFields.tsx b/packages/payload/src/admin/components/forms/RenderFields/filterFields.tsx
index 472927002cd..243d6187634 100644
--- a/packages/payload/src/admin/components/forms/RenderFields/filterFields.tsx
+++ b/packages/payload/src/admin/components/forms/RenderFields/filterFields.tsx
@@ -48,23 +48,24 @@ export const filterFields = (args: {
         }
 
         const isFieldAffectingData = fieldAffectsData(field)
-
         const fieldPermissions = isFieldAffectingData ? permissions?.[field.name] : permissions
 
+        // if the user cannot read the field, then filter it out
+        if (fieldPermissions?.read?.permission === false) {
+          return acc
+        }
+
+        // readOnly from field config
         let readOnly = field.admin && 'readOnly' in field.admin ? field.admin.readOnly : undefined
 
+        // if parent field is readOnly
+        // but this field is `readOnly: false`
+        // the field should be editable
         if (readOnlyOverride && readOnly !== false) readOnly = true
 
-        if (
-          (isFieldAffectingData && permissions?.[field?.name]?.read?.permission !== false) ||
-          !isFieldAffectingData
-        ) {
-          if (
-            isFieldAffectingData &&
-            permissions?.[field?.name]?.[operation]?.permission === false
-          ) {
-            readOnly = true
-          }
+        // unless the user does not pass access control
+        if (fieldPermissions?.[operation]?.permission === false) {
+          readOnly = true
         }
 
         if (FieldComponent) {
Repository: payloadcms/payload (TypeScript)

Issue:
Disabling GraphQL on a global causes Payload to generate an invalid GraphQL schema
### Link to reproduction

https://github.com/diesieben07/payload/tree/issue/disable-graphql

### To Reproduce

Set `graphQL: false` on a global

### Describe the Bug

When GraphQL is disabled, Payload generates an invalid GraphQL schema for the `Access` type. It creates a field for the global in the Access type, but sets its type to `null`, which GraphQL then rightfully complains about.

### Payload Version

2.0.10

### Adapters and Plugins

n/a



Fix (patch):
diff --git a/packages/payload/src/graphql/schema/buildPoliciesType.ts b/packages/payload/src/graphql/schema/buildPoliciesType.ts
index 5929787fea8..999c34218fb 100644
--- a/packages/payload/src/graphql/schema/buildPoliciesType.ts
+++ b/packages/payload/src/graphql/schema/buildPoliciesType.ts
@@ -217,6 +217,9 @@ export default function buildPoliciesType(payload: Payload): GraphQLObjectType {
   })
 
   Object.values(payload.config.globals).forEach((global: SanitizedGlobalConfig) => {
+    if (global.graphQL === false) {
+      return
+    }
     const globalPolicyType = buildPolicyType({
       entity: global,
       type: 'global',
Repository: TanStack/form (TypeScript)

Issue:
Unmounting a field does not update the form
### Describe the bug

Hi,

I just noticed a bug unmounting a field: the state and fieldInfo of the field is preserved in the form even after unmounting it. 

To illustrate I added some expects to the `unmount` test:
```js
     // Field should have been removed from the form as well
    expect(form.state.values.name).toBeUndefined()
    expect(form.state.fieldMeta.name).toBeUndefined()
```
These last assertions fail at the moment. 

### Your minimal, reproducible example

https://github.com/TanStack/form/pull/501

### Steps to reproduce

1. Run the tests
2. they fail

### Expected behavior

Tests pass

### How often does this bug happen?

Every time

### Screenshots or Videos

_No response_

### Platform

- Jest

### Tanstack Form adapter

None

### TanStack Form version

latest

### TypeScript version

_No response_

### Additional context

_No response_



Fix (patch):
diff --git a/packages/form-core/src/FieldApi.ts b/packages/form-core/src/FieldApi.ts
index ff718dbe4..418719d1c 100644
--- a/packages/form-core/src/FieldApi.ts
+++ b/packages/form-core/src/FieldApi.ts
@@ -243,6 +243,7 @@ export class FieldApi<
       unsubscribe()
       if (!preserveValue) {
         delete info.instances[this.uid]
+        this.form.deleteField(this.name)
       }
 
       if (!Object.keys(info.instances).length && !preserveValue) {
Repository: TanStack/form (TypeScript)

Issue:
DeepKeys type not working with all partial object
### Describe the bug

`DeepKeys` not working with all partial object, expect returns object keys, but returns `string`.

### Your minimal, reproducible example

see Steps to reproduce

### Steps to reproduce

```ts
import type { DeepKeys } from "@tanstack/react-form";

type AllPartialObject = {
  a?: string;
  b?: number;
  c?: {
    c1: string;
    c2: string;
  };
};

// it returns string
type AllPartialObjectKeys = DeepKeys<AllPartialObject>;

type PartPartialObject = {
  a?: string;
  b: string;
  c?: {
    c1: string;
    c2: string;
  };
};

// it returns "a" | "b" | "c" | "c.c1" | "c.c2" | undefined
type PartPartialObjectKeys = DeepKeys<PartPartialObject>;
```

### Expected behavior

DeepKeys<AllPartialObject> returns all object keys.

### How often does this bug happen?

None

### Screenshots or Videos

_No response_

### Platform

No need.

### TanStack Form adapter

None

### TanStack Form version

v0.20.3

### TypeScript version

v5.2.2

### Additional context

_No response_


Discussion: Thanks! Adding one more case I found with one partial nested field:

```ts
type NestedPartialObject = {
  c: {
    c1?: string
    c2: string
  }
}

// "c" | "cundefined" | "c.c1" | "c.c2"
type PartPartialObjectKeys = DeepKeys<NestedPartialObject>
```




Fix (patch):
diff --git a/packages/form-core/src/util-types.ts b/packages/form-core/src/util-types.ts
index 29f238527..25dd9f61b 100644
--- a/packages/form-core/src/util-types.ts
+++ b/packages/form-core/src/util-types.ts
@@ -60,7 +60,7 @@ type PrefixTupleAccessor<
 }[TIndex]
 
 type PrefixObjectAccessor<T extends object, TDepth extends any[]> = {
-  [K in keyof T]: K extends string | number
+  [K in keyof T]-?: K extends string | number
     ?
         | PrefixFromDepth<K, TDepth>
         | `${PrefixFromDepth<K, TDepth>}${DeepKeys<T[K], [TDepth]>}`
@@ -71,19 +71,17 @@ export type DeepKeys<T, TDepth extends any[] = []> = TDepth['length'] extends 5
   ? never
   : unknown extends T
     ? PrefixFromDepth<string, TDepth>
-    : object extends T
-      ? PrefixFromDepth<string, TDepth>
-      : T extends readonly any[] & IsTuple<T>
-        ? PrefixTupleAccessor<T, AllowedIndexes<T>, TDepth>
-        : T extends any[]
-          ? PrefixArrayAccessor<T, [...TDepth, any]>
-          : T extends Date
-            ? never
-            : T extends object
-              ? PrefixObjectAccessor<T, TDepth>
-              : T extends string | number | boolean | bigint
-                ? ''
-                : never
+    : T extends readonly any[] & IsTuple<T>
+      ? PrefixTupleAccessor<T, AllowedIndexes<T>, TDepth>
+      : T extends any[]
+        ? PrefixArrayAccessor<T, [...TDepth, any]>
+        : T extends Date
+          ? never
+          : T extends object
+            ? PrefixObjectAccessor<T, TDepth>
+            : T extends string | number | boolean | bigint
+              ? ''
+              : never
 
 type PrefixFromDepth<
   T extends string | number,
Repository: TanStack/form (TypeScript)

Issue:
form.Subscribe is only re-rendered if input length > 1  
### Describe the bug

As soon as the input validation fails the first time, the children of form.Subscribe are only re-rendered with the correct value of `canSubmit` if the input length is longer than 1 character.

### Your minimal, reproducible example

https://codesandbox.io/p/sandbox/musing-microservice-gpzhn3?embed=1&file=/src/index.tsx:18,25

### Steps to reproduce

1. Go to code sandbox: https://codesandbox.io/p/sandbox/musing-microservice-gpzhn3?embed=1&file=/src/index.tsx:18,25
2. type something into the input field, then delete everything
3. type again something into the input field


### Expected behavior

The submit button should be activated as soon as the input field is validated correctly, however here it only happens after two characters were typed into the input field.

### How often does this bug happen?

Every time

### Screenshots or Videos


https://github.com/TanStack/form/assets/6340397/76969c07-049e-4507-9fcd-baa7c002f03e



### Platform

- OS: macOS
- Browser (Firefox and Chrome)

### Tanstack Form adapter

react-form

### TanStack Form version

0.3.4

### TypeScript version

_No response_

### Additional context

_No response_



Fix (patch):
diff --git a/packages/form-core/src/FormApi.ts b/packages/form-core/src/FormApi.ts
index 862e2fa2b..678267546 100644
--- a/packages/form-core/src/FormApi.ts
+++ b/packages/form-core/src/FormApi.ts
@@ -134,8 +134,10 @@ export class FormApi<TFormData, ValidatorType> {
             (field) => field?.isValidating,
           )
 
-          const isFieldsValid = !fieldMetaValues.some((field) =>
-            isNonEmptyArray(field?.errors),
+          const isFieldsValid = !fieldMetaValues.some(
+            (field) =>
+              field?.errorMap &&
+              isNonEmptyArray(Object.values(field.errorMap).filter(Boolean)),
           )
 
           const isTouched = fieldMetaValues.some((field) => field?.isTouched)
Repository: TanStack/form (TypeScript)

Issue:
`form.onSubmitInvalid` not called when `canSubmit` is false
### Describe the bug

When `handleSubmit` is called while `canSubmit` is `false` an early return is hit and `onSubmitInvalid` is not called.

https://github.com/TanStack/form/blob/1e58e57987e4f79fb23d0034d1cdceebb9a7299b/packages/form-core/src/FormApi.ts#L1918

### Your minimal, reproducible example

https://stackblitz.com/edit/tanstack-form-dqy8vhes?file=src%2Findex.tsx

### Steps to reproduce

1. Go to the Stackblitz
2. 👁️ Observe: `"canSubmit": false,` (see JSON-dump in `<pre>`-Tag)
3. Click the Submit Button
4. 👁️ Observe: No `console.log` for `"onSubmitInvalid"`

### Expected behavior

As a User I expect `form.onSubmitInvalid` to be called whenever the form is submitted in an invalid state

### How often does this bug happen?

Every time

### Screenshots or Videos

_No response_

### Platform

irrelevant

### TanStack Form adapter

react-form

### TanStack Form version

1.19.2

### TypeScript version

_No response_

### Additional context

_No response_



Fix (patch):
diff --git a/.changeset/brown-cars-smell.md b/.changeset/brown-cars-smell.md
new file mode 100644
index 000000000..6532c7351
--- /dev/null
+++ b/.changeset/brown-cars-smell.md
@@ -0,0 +1,5 @@
+---
+'@tanstack/form-core': patch
+---
+
+fix(form-core): call `onSubmitInvalid` even when `canSubmit` is false
diff --git a/packages/form-core/src/FormApi.ts b/packages/form-core/src/FormApi.ts
index 6afa0fdc9..611941b19 100644
--- a/packages/form-core/src/FormApi.ts
+++ b/packages/form-core/src/FormApi.ts
@@ -2014,11 +2014,18 @@ export class FormApi<
       )
     })
 
-    if (!this.state.canSubmit && !this._devtoolsSubmissionOverride) return
-
     const submitMetaArg =
       submitMeta ?? (this.options.onSubmitMeta as TSubmitMeta)
 
+    if (!this.state.canSubmit && !this._devtoolsSubmissionOverride) {
+      this.options.onSubmitInvalid?.({
+        value: this.state.values,
+        formApi: this,
+        meta: submitMetaArg,
+      })
+      return
+    }
+
     this.baseStore.setState((d) => ({ ...d, isSubmitting: true }))
 
     const done = () => {
Repository: apache/datafusion (Rust)

Issue:
Error on Join: Schema error: Schema contains duplicate unqualified field name 
### Describe the bug

When trying to join two relations that have a column with the same name, we see an error

> Schema error: Schema contains duplicate unqualified field name cron_job_name

### To Reproduce

```
DataFusion CLI v27.0.0
❯ SELECT *
FROM (
VALUES ('catan-prod1-daily', 'success')
) as jobs(cron_job_name, status)
JOIN (
VALUES ('catan-prod1-daily', 'high')
) as severity(cron_job_name, level) ON (severity.cron_job_name =
jobs.cron_job_name);
Schema error: Schema contains duplicate unqualified field name cron_job_name
❯
```

### Expected behavior

Query should run


### Additional context

_No response_



Fix (patch):
diff --git a/datafusion/sql/src/planner.rs b/datafusion/sql/src/planner.rs
index 26ff5466f408..efa3077c3b59 100644
--- a/datafusion/sql/src/planner.rs
+++ b/datafusion/sql/src/planner.rs
@@ -34,7 +34,7 @@ use datafusion_common::{OwnedTableReference, TableReference};
 use datafusion_expr::logical_plan::{LogicalPlan, LogicalPlanBuilder};
 use datafusion_expr::utils::find_column_exprs;
 use datafusion_expr::TableSource;
-use datafusion_expr::{col, AggregateUDF, Expr, ScalarUDF, SubqueryAlias};
+use datafusion_expr::{col, AggregateUDF, Expr, ScalarUDF};
 
 use crate::utils::make_decimal_type;
 
@@ -222,18 +222,17 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
         Ok(Schema::new(fields))
     }
 
-    /// Apply the given TableAlias to the top-level projection.
+    /// Apply the given TableAlias to the input plan
     pub(crate) fn apply_table_alias(
         &self,
         plan: LogicalPlan,
         alias: TableAlias,
     ) -> Result<LogicalPlan> {
-        let apply_name_plan = LogicalPlan::SubqueryAlias(SubqueryAlias::try_new(
-            plan,
-            self.normalizer.normalize(alias.name),
-        )?);
+        let plan = self.apply_expr_alias(plan, alias.columns)?;
 
-        self.apply_expr_alias(apply_name_plan, alias.columns)
+        LogicalPlanBuilder::from(plan)
+            .alias(self.normalizer.normalize(alias.name))?
+            .build()
     }
 
     pub(crate) fn apply_expr_alias(