Skip to content

Boolean credentials incorrectly classified as "json" in secret .metadata field #606

@mario-fazli

Description

@mario-fazli

Problem

When a service binding contains boolean fields in the credentials (e.g., saasregistryenabled: true), the .metadata field in the generated Kubernetes secret incorrectly classifies these fields as format "json" instead of a more appropriate type like "text" or "boolean".

Example

Service Manager Binding Response:

{
  "credentials": {
    "saasregistryenabled": true,
    "uaa": {...},
    "url": "https://example.com"
  }
}

Generated Secret .metadata field:

{
  "credentialProperties": [
    {"name": "saasregistryenabled", "format": "json"},
    {"name": "uaa", "format": "json"},               
    {"name": "url", "format": "text"}              
  ],
  "metaDataProperties": [...]
}

Root Cause

The issue is in the serialize() function in internal/utils/controller_util.go (lines 151-162). It defaults to JSON for all non-string values:

func serialize(value interface{}) ([]byte, format, error) {
	if byteArrayVal, ok := value.([]byte); ok {
		return byteArrayVal, JSON, nil
	}
	if strVal, ok := value.(string); ok {
		return []byte(strVal), TEXT, nil
	}
	data, err := json.Marshal(value)
	if err != nil {
		return nil, UNKNOWN, err
	}
	return data, JSON, nil 
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions