Giter Site home page Giter Site logo

Comments (20)

juliemturner avatar juliemturner commented on August 17, 2024 1

Yes, we've confirmed that this is a bug in that we don't support calls that return 204 in batches, we'll update this to fix it in a future release.

from pnpjs.

juliemturner avatar juliemturner commented on August 17, 2024

The release you're referencing is very stable, so I suspect something you have set up isn't correct. I can't really help you without any code showing what you're doing and what line the error is happening on. I'm going to guess that you don't have any behaviors set up... but again just a shot in the dark without any further information.

from pnpjs.

RoelVB avatar RoelVB commented on August 17, 2024

Hi @juliemturner
Thank you for the prompt response. I'm sorry I didn't have time to create a short code to reproduce this issue. As it occurs as part of a complex piece of code.

I've worked out a compact example which causes the error:

import { graphfi } from '@pnp/graph';
import '@pnp/graph/teams';
import '@pnp/graph/batching';
import { GraphDefault } from '@pnp/nodejs';

const graph = graphfi().using(GraphDefault({
    baseUrl: 'https://graph.microsoft.com',
    msal: {
        config: {
            auth: {
                clientId: '<CLIENTID>>',
                clientSecret: '<CLIENTSECRET>>',
                authority: '<AUTHORITY>',
            },
        },
        scopes: [ 'https://graph.microsoft.com/.default' ]
    }
}));

// The MSTeam ID we're going to test with
const TESTTEAM = '<SOME GUID>';

(async ()=>{
    // Get the first channel from the Team (there seems to be a typing issue here, so we cast it to any for now)
    const testChannel: any = (await graph.teams.getById(TESTTEAM).channels())[0];
    console.log(`Testing with channel "${testChannel.displayName}"`);

    // Create a new tab
    const newTab = await graph.teams.getById(TESTTEAM).channels.getById(testChannel.id).tabs.add(
        'PnPJS Test',
        'https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/com.microsoft.teamspace.tab.web',
        {
            configuration: {
                contentUrl: 'https://www.google.com',
                websiteUrl: 'https://www.google.com',
            }
        }
    );
    
    // Remove the created tab in a batched request
    const [batch,execute] = graph.batched();
    batch.teams.getById(TESTTEAM).channels.getById(testChannel.id).tabs.getById(newTab.data.id).delete();

    try {
        await execute();
    } catch(error) {
        console.error('Something went wrong.', error); // We the "Cannot read property 'Content-Type' of undefined" error here
    }
})();

This code creates a tab in a Teams channel and successfully removes it, but still throws an error.
Calling the delete() outside of the batch works without any error.

from pnpjs.

juliemturner avatar juliemturner commented on August 17, 2024

Ok, so to summarize the delete teams tab call works but doesn't work batched? That's a distinct possibility because not all calls work batched, but it may be something we can fix. I'll look into it further.

from pnpjs.

RoelVB avatar RoelVB commented on August 17, 2024

@juliemturner
No, the call is successful, but PnPJS throws an error, because it tries to get a response header that isn't there.
The batched call returns HTTP 204 and the tab is actually deleted.

In this case, response.headers is undefined at this point:

const contentType = response.headers["Content-Type"];

Also... the tab deletion is an example. I've seen it with other batched deletes.

from pnpjs.

RoelVB avatar RoelVB commented on August 17, 2024

I would gladly provide a PR, but I'm not sure what would be the desired way to fix this.
Quick and dirty would be just changing the line mentioned to:

const contentType = response.headers?.["Content-Type"]; 

from pnpjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.