Google Professional Cloud Developer Question 319
Select 2Google Cloud PlatformYou are working on a microservices-based application deployed on Google Kubernetes Engine (GKE). Your team is about to release a new version of a REST API that introduces additional fields in the response payload but keeps all existing fields unchanged. How can you ensure backward compatibility with existing clients?
- A
Ensure that all existing fields in the API response remain unchanged in both name and data type.
- B
Notify clients to update their applications to handle the additional fields before deploying the new version.
- C
Use semantic versioning to indicate that the API introduces a non-breaking change.
- D
Remove deprecated fields from the API response to simplify the payload and reduce client-side confusion.
Show answer and explanation
Correct answers: A, C
Explanation
Backward compatibility ensures that existing clients can continue to function without modification when a new version of an API is released. To achieve this, existing fields must remain unchanged, and semantic versioning should be used to communicate non-breaking changes to clients. Adding new fields to a response payload is considered backward-compatible as long as existing fields are preserved.
- A. Correct.
Ensuring that existing fields remain unchanged is essential for backward compatibility. This allows existing clients to continue functioning without modification.
- B. Incorrect.
Requiring clients to update their applications before deployment contradicts the principle of backward compatibility, as it breaks the smooth operation of existing clients.
- C. Correct.
Semantic versioning provides a clear way to indicate compatibility to API consumers. A minor version increment is typically used for non-breaking changes like adding new fields.
- D. Incorrect.
Removing deprecated fields without prior communication or transition planning could break existing clients relying on those fields, which violates backward compatibility principles.