Open
Conversation
…verError - Remove unused datetime import and current_date variable calculation - Replace InternalServerError with EnvironmentError for environment variable validation - Simplify error handling for SERVICE_NAMESPACE and CONTRACT_STATUS_TABLE checks - InternalServerError is not appropriate for environment configuration issues that occur at module initialization
…d remove unused metric - Add validation for evaluation_result to ensure only "APPROVED" or "DECLINED" values are processed - Return early with skip message when unknown evaluation result is encountered - Log warning when evaluation result is invalid for debugging purposes - Remove unused PropertiesAdded metric that was not being utilized - Improve robustness by preventing invalid data from being written to DynamoDB
…trics - Import timezone from datetime module for UTC timestamp generation - Import MetricUnit from aws_lambda_powertools.metrics for proper metric typing - Replace strftime formatting with isoformat() for ISO 8601 compliant timestamps in create_contract and update_contract functions - Add metric tracking for successful contract creation events - Rename UpdateExpression attribute from modified_date to contract_last_modified_on for consistency - Ensures timestamps are timezone-aware and use UTC for consistency across distributed systems
- Add actions: read permission for workflow execution access - Add contents: read permission for repository content access - Scope down GitHub Token permissions following security best practices
This was referenced Mar 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue number: #178
Summary
Changes
Fixes to align the Python runtime with Java, TypeScript, and .NET for functional equivalence and cross-runtime consistency.
Contracts Service (
unicorn_contracts)create_contract: replaceddatetime.now().strftime("%d/%m/%Y %H:%M:%S")withdatetime.now(timezone.utc).isoformat()for bothcontract_createdandcontract_last_modified_onupdate_contract: changedUpdateExpressionfrom"set contract_status=:t, modified_date=:m"to"set contract_status=:t, contract_last_modified_on=:m"— fixes a bug where updates wrote to a non-existentmodified_dateattributeupdate_contract: updated timestamp to usedatetime.now(timezone.utc).isoformat()metrics.add_metric(name="ContractCreated", unit=MetricUnit.Count, value=1)tocreate_contractsuccess pathApprovals Service (
unicorn_approvals)contract_status_changed_event_handler: movednow = datetime.now()andcurrent_datecomputation inside the handler function body to capture per-invocation time rather than container initialisation timeraise InternalServerError(...)withraise EnvironmentError(...)for missingSERVICE_NAMESPACEandCONTRACT_STATUS_TABLEenvironment variables; removed unusedInternalServerErrorimportWeb Service (
unicorn_web)publication_evaluation_event_handler: added validation guard — only updates DynamoDB whenevaluation_resultis"APPROVED"or"DECLINED"; logs a warning and returns for any other valuePropertiesApprovedmetric — removed the duplicatePropertiesAddedmetricUser experience
Before: Timestamps used a custom locale-specific format (
DD/MM/YYYY HH:MM:SS) incompatible with other runtimes. Theupdate_contractfunction silently wrote to a wrong DynamoDB attribute (modified_date). The approvals handler captured timestamps at container init time. The publication evaluation handler processed all evaluation result values without validation.After: Timestamps use ISO 8601 format (
YYYY-MM-DDTHH:MM:SS.ffffff+00:00) consistent with Java, TypeScript, and .NET. Contract updates correctly write tocontract_last_modified_on. Each invocation captures its own timestamp. The publication evaluation handler only processes known result values, ignoring unexpected ones with a warning.Checklist
Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.