Skip to content

Commit

Permalink
Changed the responds status code from 500 to 501 for not implemented …
Browse files Browse the repository at this point in the history
…API (#2517)
  • Loading branch information
blueww authored Jan 2, 2025
1 parent d95c7cc commit 3e25ee5
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
## Upcoming Release

General:

- Changed the responds status code of not implemented API from 500 to 501.

Blob:

- GetBlob on Archive tier blobs now fails as expected.
Expand Down
20 changes: 19 additions & 1 deletion src/blob/errors/NotImplementedError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,28 @@ import StorageError from "./StorageError";
export default class NotImplementedError extends StorageError {
public constructor(requestID: string = "") {
super(
500,
501,
"APINotImplemented",
"Current API is not implemented yet. Please vote your wanted features to https://github.com/azure/azurite/issues",
requestID
);
}
}

/**
* Create customized error types by inheriting ServerError
*
* @export
* @class UnimplementedError
* @extends {StorageError}
*/
export class NotImplementedinSQLError extends StorageError {
public constructor(requestID: string = "") {
super(
501,
"APINotImplemented",
"Current API is not implemented yet when use a SQL database based metadata storage. Please vote your wanted features to https://github.com/azure/azurite/issues",
requestID
);
}
}
17 changes: 9 additions & 8 deletions src/blob/persistence/SqlBlobMetadataStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import PageWithDelimiter from "./PageWithDelimiter";
import FilterBlobPage from "./FilterBlobPage";
import { getBlobTagsCount, getTagsFromString, toBlobTags } from "../utils/utils";
import { generateQueryBlobWithTagsWhereFunction } from "./QueryInterpreter/QueryInterpreter";
import { NotImplementedinSQLError } from "../errors/NotImplementedError";

// tslint:disable: max-classes-per-file
class ServicesModel extends Model { }
Expand Down Expand Up @@ -1831,7 +1832,7 @@ export default class SqlBlobMetadataStore implements IBlobMetadataStore {
}

public undeleteBlob(): Promise<void> {
throw new Error("Method not implemented.");
throw new NotImplementedinSQLError();
}

public async createSnapshot(
Expand Down Expand Up @@ -2756,7 +2757,7 @@ export default class SqlBlobMetadataStore implements IBlobMetadataStore {
copySource: string,
metadata: Models.BlobMetadata | undefined
): Promise<Models.BlobPropertiesInternal> {
throw new Error("Method not implemented.");
throw new NotImplementedinSQLError(context.contextId);
}

public setTier(
Expand Down Expand Up @@ -2866,7 +2867,7 @@ export default class SqlBlobMetadataStore implements IBlobMetadataStore {
leaseAccessConditions?: Models.LeaseAccessConditions,
modifiedAccessConditions?: Models.ModifiedAccessConditions
): Promise<Models.BlobPropertiesInternal> {
throw new Error("Method not implemented.");
throw new NotImplementedinSQLError(context.contextId);
}

public clearRange(
Expand All @@ -2877,7 +2878,7 @@ export default class SqlBlobMetadataStore implements IBlobMetadataStore {
leaseAccessConditions?: Models.LeaseAccessConditions,
modifiedAccessConditions?: Models.ModifiedAccessConditions
): Promise<Models.BlobPropertiesInternal> {
throw new Error("Method not implemented.");
throw new NotImplementedinSQLError(context.contextId);
}

public getPageRanges(
Expand All @@ -2889,7 +2890,7 @@ export default class SqlBlobMetadataStore implements IBlobMetadataStore {
leaseAccessConditions?: Models.LeaseAccessConditions,
modifiedAccessConditions?: Models.ModifiedAccessConditions
): Promise<GetPageRangeResponse> {
throw new Error("Method not implemented.");
throw new NotImplementedinSQLError(context.contextId);
}

public resizePageBlob(
Expand All @@ -2901,7 +2902,7 @@ export default class SqlBlobMetadataStore implements IBlobMetadataStore {
leaseAccessConditions?: Models.LeaseAccessConditions,
modifiedAccessConditions?: Models.ModifiedAccessConditions
): Promise<Models.BlobPropertiesInternal> {
throw new Error("Method not implemented.");
throw new NotImplementedinSQLError(context.contextId);
}

public updateSequenceNumber(
Expand All @@ -2912,7 +2913,7 @@ export default class SqlBlobMetadataStore implements IBlobMetadataStore {
sequenceNumberAction: Models.SequenceNumberActionType,
blobSequenceNumber: number | undefined
): Promise<Models.BlobPropertiesInternal> {
throw new Error("Method not implemented.");
throw new NotImplementedinSQLError(context.contextId);
}

public appendBlock(
Expand All @@ -2924,7 +2925,7 @@ export default class SqlBlobMetadataStore implements IBlobMetadataStore {
| Models.AppendPositionAccessConditions
| undefined
): Promise<Models.BlobPropertiesInternal> {
throw new Error("Method not implemented.");
throw new NotImplementedinSQLError(context.contextId);
}

public async listUncommittedBlockPersistencyChunks(
Expand Down
2 changes: 1 addition & 1 deletion src/queue/errors/NotImplementedError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import StorageError from "./StorageError";
export default class NotImplementedError extends StorageError {
public constructor(requestID: string = "") {
super(
500,
501,
"APINotImplemented",
"Current API is not implemented yet. Please vote your wanted features to https://github.com/azure/azurite/issues",
requestID
Expand Down

0 comments on commit 3e25ee5

Please sign in to comment.