Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README.md snippet does not compile #31883

Open
1 of 6 tasks
chrisribe opened this issue Nov 21, 2024 · 4 comments
Open
1 of 6 tasks

README.md snippet does not compile #31883

chrisribe opened this issue Nov 21, 2024 · 4 comments
Labels
Client This issue points to a problem in the data-plane of the library. Health Deidentification Health Deidentification service Service Attention Workflow: This issue is responsible by Azure service team.

Comments

@chrisribe
Copy link
Member

chrisribe commented Nov 21, 2024

Describe the bug

  • The current documentation snippet does not compile because calling await outside of an async function is invalid.
  • The use of isUnexpected is invalid in this context response.ts does not have this defined. Expected output interface is DeidentificationResultOutput

To Reproduce
Steps to reproduce the behavior:

  1. Take snippet code + tsc compile + run

Expected behavior
Expecting a working simple snippet

Screenshots
Image

Additional context
Code suggestion: Provide a more robust sample in TypeScript and Plain JS.

PlainJS

const { DefaultAzureCredential } = require("@azure/identity");
const createClient = require("@azure-rest/health-deidentification").default;
const dotenv = require("dotenv");
dotenv.config();

const credential = new DefaultAzureCredential();
const serviceEndpoint = "<xyz-url>.api.deid.azure.com";
const client = createClient(serviceEndpoint, credential);

const content = {
  inputText: "Hello John!"
};

async function postToDeid() {
  console.log("Posting:", content.inputText);
  const response = await client.path("/deid").post({ body: content });

  if(response.status == 200){
	console.log("Result:", response.body.outputText);
  }
  else if (response.body && response.body.error) {
    throw response.body.error;
  } else {
    throw new Error(`Unexpected response without error details. Status: ${response.status}, Headers: ${JSON.stringify(response.headers)}, Body: ${JSON.stringify(response.body)}`);	
  }
}

postToDeid().catch((err) => {
  if (err instanceof Error) {
    console.error("Error message:", err.message);
    console.error("Error stack:", err.stack);
    console.error("Error details:", err);
  } else {
    console.error("Unknown error:", err);
  }
});
@github-actions github-actions bot added Azure.Identity Client This issue points to a problem in the data-plane of the library. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team labels Nov 21, 2024
Copy link

@KarishmaGhiya @maorleger

Copy link

Thank you for your feedback. Tagging and routing to the team member best able to assist.

@chrisribe chrisribe added Health Deidentification Health Deidentification service and removed Client This issue points to a problem in the data-plane of the library. Azure.Identity needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team labels Nov 21, 2024
@jeremymeng jeremymeng added Client This issue points to a problem in the data-plane of the library. Service Attention Workflow: This issue is responsible by Azure service team. labels Nov 21, 2024
Copy link

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @GrahamMThomas.

@jeremymeng
Copy link
Member

/cc @danielszaniszlo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. Health Deidentification Health Deidentification service Service Attention Workflow: This issue is responsible by Azure service team.
Projects
Status: Untriaged
Development

No branches or pull requests

3 participants