Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[Bug] Table-mode create/update sends a JSON body without a Content-Type header, so the SQL Server connector rejects inserts with 415 "media type 'text/plain' is not supported

Aperta
#44 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@tonystevenj ci sta già lavorando.

Dal 20/10/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

bug

Describe the bug

In @microsoft/managed-apps 0.5.11 (which uses @microsoft/managed-apps-common 0.19.0), creating a record through a table-mode data source fails against the SQL Server connector (shared_sql) with HTTP 415.

RuntimeDataClient.createDataAsync (dist/dataClient/data/runtimeDataClient.js, line 49) serializes the record with body: JSON.stringify(body) but sets no Content-Type. _createHeaders() only adds Accept: application/json, x-ms-protocol-semantics: cdp, ServiceNamespace and x-ms-enable-selects. The string body then goes through host.sendHttpRequest with no content type. It arrives at the connector as text/plain, which is also the fetch default for a string body, and the connector rejects it.

updateDataAsync (line 74) has the same pattern.

The action path is inconsistent with this: ConnectorExecutor.executeAsync (connectorExecutor.js, lines 135–139) explicitly adds Content-Type: application/json whenever a body is present.

Reads on the same data source and connection work.

Steps to Reproduce

  1. Create a code app from the App Builder v1 template. Its package.json pins "@microsoft/managed-apps": "0.5.11".

  2. Create a SQL Server (shared_sql) connection with Microsoft Entra ID Integrated authentication to a SQL database. Our repro used a Microsoft Fabric SQL database with the AdventureWorksLT sample loaded.

  3. Add a table-mode data source:

    • dataset: <server>.database.fabric.microsoft.com,<database>
    • table: [SalesLT].[SalesOrderHeader]

    This generates SalesOrderHeaderService with create, update, delete, get and getAll.

  4. Control: call

    await SalesOrderHeaderService.getAll({ top: 1 });
    

    It succeeds and returns rows.

  5. Call:

    const result = await SalesOrderHeaderService.create({
      CustomerID: 29485,
      OrderDate: "2026-10-20T00:00:00Z",
      DueDate: "2026-10-27T00:00:00Z",
      ShipMethod: "CARGO TRANSPORT 5",
      SubTotal: 100,
      TaxAmt: 0,
      Freight: 0,
    } as Omit<SalesOrderHeader, "SalesOrderID">);
    
  6. result.success is false, with HTTP 415.

Expected behavior

The POST to .../datasets/<server>,<database>/tables/[SalesLT].[SalesOrderHeader]/items is sent with Content-Type: application/json. The row is inserted and the created record is returned in result.data.

Actual behavior

The request is sent without a Content-Type header and the connector answers HTTP 415. No row is inserted.

There is no app-side workaround:

  • The data client exposes no way to set request headers for createRecordAsync / updateRecordAsync.
  • Passing a pre-stringified body gets stringified a second time.
  • The package version is pinned by the template.

Screenshots or Error Messages

SQL table insert failed
{"message":"{\"error\":{\"code\":\"\",\"message\":\"The request entity's media type 'text/plain' is not supported for this resource.\"},\"debugInfo\":\"clientRequestId: f7458049-157a-4476-b4c8-6a9d4020a2b2\"}","status":415,"requestId":"f7458049-157a-4476-b4c8-6a9d4020a2b2"}
  • First failure: 2026-10-20T15:52:31Z, clientRequestId f7458049-157a-4476-b4c8-6a9d4020a2b2
  • Second failure: 2026-10-20T15:53:00Z, clientRequestId afba0685-f72e-4beb-bf0b-2e7a393e8347, with the same 415

Relevant library code (@microsoft/managed-apps-common 0.19.0, dist/dataClient/data/runtimeDataClient.js):

async createDataAsync(url, apiId, connectionId, tableName, body, operationName) {
  const config = { url, method: HttpMethod.POST, apiId, connectionId, tableName,
                   body: JSON.stringify(body) };           // no headers -> no Content-Type
  return await this._executeRequest(config, { operationName: ... });
}
_createHeaders(config) {
  const baseHeaders = { Accept: 'application/json', 'x-ms-protocol-semantics': 'cdp',
                        ServiceNamespace: config.tableName, 'x-ms-enable-selects': 'true' };
  return config.headers ? { ...baseHeaders, ...config.headers } : baseHeaders;
}

Environment information

  • Node.js and npm version: node v24.7.0, npm 11.19.0 (bun 1.3.14 is used by the template's dev server)
  • Are you on an enterprise network (e.g. behind a corporate proxy or firewall)? Not relevant: the header is missing before the request leaves the client library. Reproduced in the hosted App Builder preview in Copilot Studio; requests are relayed by the Power Platform host.
  • Framework, build tool or relevant package used: React 19.2.5, Vite 7.3.5, TypeScript 5.8.3, @tanstack/react-query 5.100.6, @microsoft/managed-apps 0.5.11 (@microsoft/managed-apps-common 0.19.0)
  • Any connection/components: SQL Server connector (shared_sql), Microsoft Entra ID Integrated authentication, target is a Microsoft Fabric SQL database (AdventureWorksLT sample, schema SalesLT)

Additional context

  • Confirmed live for create only. update uses the same code (line 74) and should fail the same way; this was found by reading the code, not observed live.
  • The code path is not specific to SQL Server, so table-mode create and update for other tabular connectors are probably affected too. Only SQL Server was verified.
  • The same connection reads SalesOrderHeader, SalesOrderDetail, Product, ProductCategory and Customer without problems.
  • Suggested fix: set headers: { 'Content-Type': 'application/json' } in the configs built by createDataAsync and updateDataAsync, as ConnectorExecutor.executeAsync already does for action bodies.
Lingua principale
TypeScript
Stelle
27
Fork
8
Merge medio
6h 59m
PR unite (30g)
5

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/managed-apps

Tutte le issue di microsoft/managed-apps

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.